Object Oriented Programming is exceptionally bad

I quote Edsger Dijkstra (1930-2002), a great Dutch programmer and writer:

Object-oriented programming is an exceptionally bad idea which could only have originated in California.

The 3 promises

Object Oriented Programming (OOP) is promising us:

  1. hide implementation details
  2. optimal reuse of code
  3. hiding state, combining code and data

In my experience Object Oriented Programming Languages are no better at #1 and #2 than procedural languages. And #3 may seem logical as we have data and code. This code manipulates the data that should be in a well structured and preferably standardized format. But combining code and data is in my opinion not always a good idea (more on that later).

Accidental obfuscation

Unfortunately these are the characteristics of many OOP code bases I have seen:

  1. hard to learn
  2. many lines of code
  3. low performance

In most cases we do not need IoC, LSP or even SOLID. We don’t need castles built of (Java) classes. We don’t want to read 10 different classes and interfaces to understand often trivial implementations. Programming is hard enough without people accidentally obfuscating what is going on.

oop_is_bizarre

Nobody complains about OOP like Zed Shaw in the above video from exactly 17:24. Click the image to play the video from that point (takes about five minutes).

Use. Less. Classes.

While Object Oriented Programming may lead to the characteristics described above, software (developers) should focus on achieving the opposites:

  1. easy to learn
  2. few lines of code
  3. high performance

The world seems to realize this nowadays. We see that new non-OOP languages like Rust and Go are emerging, while established OOP languages like C++ and Ruby are struggling. Also, make sure you watch Jack Diederich “Stop Writing Classes” talk from PyCon 2012:


stop_writing_classes

Definitely a video worth watching.  Click on the image above to start the video.

Where we really take it too far

You may argue Object Oriented has its place in some software niches. But in the database world (administrative applications) it has not. A database record is not an object. Data should not (and can not) be abstracted. Object Relational Mapping and object oriented data API’s are taking OOP way too far.

You cannot make abstractions to anticipate on future (data model) changes. How are you going to abstract missing data? Or added data? Versioning an API is fine, as long as the API is not exposing data. Behavior can be versioned and the versions can co-exist. But versioned contracts on data and it’s structure do not make sense to me.

Conclusion

Mixing code and data is not always a good idea. OOP is based on this idea. Therefor do not apply OOP without some critical thinking first.

Further reading

Much more has been said about OOP and it being a bad idea. These links are in no particular order:

If you feel like learning about this somewhat controversial point-of-view, then I recommend you to read the list above.

 

Share

8 thoughts on “Object Oriented Programming is exceptionally bad”

  1. C++ is not struggling. It has 10000x the user base of go/rust. It’s still the likely choice over those languages because it has much better tooling, optimizes better, works on more platforms, and it’s stable. It’ll be years before go/rust catch up and by then C++ will likely have acquired their main differentiating features.

  2. @Anon: Thank you for your comment. You are right, C++ is definitely older and more mature.

  3. @Julian/@Hoo: Thank you for the links, interesting reads!

  4. Thanks for the interesting pointers. One of the things we’ve tried to not do with 8th is make it an OOP language; certainly, OOP fans will agree we’ve achieved that goal.

    As Zed Shaw points out, “classes” are not usually good models of the real world… nevertheless, they can be useful in some instances. It’s just the pain that Java and C++ put you through to get there is completely pointless.

  5. @Ron It seems you created your own programming language, I like that! I am reading the tutorial and the manual and it is refreshingly different, well done.

  6. @Maurits: Thanks for the kind words. If you have suggestions or comments specific to 8th, please consider joining the forum and posting there.

    Best regards,
    Ron

Leave a Reply

Your email address will not be published. Required fields are marked *