Ask freeCodeCamp: Why do some programmers hate Object-Oriented Programming (OOP)?

Ask freeCodeCamp: Why do some programmers hate Object-Oriented Programming (OOP)?
0

#1

Some great programmers have publicly belittled OOP. Alexander Stepanov, the primary designer and implementer of the C++ Standard Template Library, said OOP provides a mathematically-limited viewpoint and called it “almost as much of a hoax as Artificial Intelligence” (it’s safe to say he got it wrong about AI). Edsger W. Dijkstra apparently compared it to snake oil. Many have ranted against it on their blogs. There are many who swear by procedural or functional programming. But why does hate exist toward OOP? Is it because, due to its focus on data abstraction, it’s considered to be against the hacker ethic? Is it just too complicated?

I’m a coding newbie; I started learning OOP a week back and still trying to get my head around it, so please excuse my naivety. As always, I appreciate all answers. Thank you.


#2

I’ve never heard anyone rant against OOP’s - when someone rants - you have to take into account their background - if someone implemented the C++ Standard Template Library they’d have a vested interest in turning people away from OOP…i’m not even sure what mathematically limited viewpoint means.

I believe Mr Stepanov is probably stuck in the past were there wasn’t really ‘computer science’ and to learn computers you had to do ECE and thus a lot of math.


#3

Everyone wants to be a rebel, I guess, and by making big sweeping categorical denouncements, one really gets the attention of everyone else to show what a plucky iconoclast they are. Doesn’t hurt to be an egotist too, because of course the ignorant sheeple all have to be educated about how horrible X is and how great Y is, and who else but to dispense this revealed wisdom?

Doesn’t even have to be about computers.


#4

This is not an easy question to answer, and I wouldn’t pretend to be the one who could answer it. I can try to give a summation:

  1. OOP does not adequately provide the benefits it claims to.
  2. The paradigm forces programmers to think about code as abstract, almost Platonic objects.
  3. Conversely, procedural code is more efficient as it allows the programmer to program without the added overhead of abstracting objects

There are more reasons, but I forget them. If you look hard enough, you’ll find people bashing just about anything. I can’t count the number of headlines I’ve seen claiming that JavaScript, and everything written in it, are a flaming garbage heap. Who cares?

I will say that you shouldn’t simply discount critics of OOP. It’s important to understand where they’re coming from because it will make you a better programmer. Some people learn OOP and try to adhere to it absolutely, which sometimes makes for near comically messy code. It’s also important to not take any of their criticisms personally. Even if OOP is poopy, it doesn’t mean that you’re a bad person for using it. It’s easy to clutch onto an emotional defense when a person starts making negative comments, but just remember that their opinion is on the code paradigm, not your worth.

OOP is an Expensive Disaster Which Must End is one of my favorite blog articles on programming. Read it carefully.


#5

There’s a saying that I’m going to paraphrase

There are two kinds of programming languages - the languages people argue about the and the languages no one uses.

In any ‘group’ of things - Comic Books, TV Shows, Computer Languages, you’re going to have favorites and least favorites, and you’re going to have zealots, evangelists, and (god forgive me for using this stupid word) haters. It’s just the way things go - especially on the internet - it’s easy to rant and rave behind a screen

Try languages - find the one that works for you and that’s all that really matters -

PS - what’s wrong with thinking of code as abstract - i never erally understood a lot of programming ideas until I got to OOP - and honestly - i hate Python but love Ruby

I think the blog writer just hates douglas coupland (that’s kind of obscure but hopefully ONE person here read the book?)


#6

The freedom of choice one has with Javascript isn’t available in every language.

I think a lot of hate comes from people who are forced to use OOP in every context.

In Java everything is an Object. Whenever you want to run just a little piece of code (like function) you will have to

  • Come up with a Noun that describes the behaviour
  • Write all the Class definition cruft around your code
  • Think about if you might want to use an interface too
  • Think about how it all fits in your Type Hierarchy
  • Think about how and where instance can be created (Singleton, Builder, Factory, new)
  • Think about how dependencies get wired into the object

For some people all this became second nature and people started to solve problems in terms of “How can I solve this using Classes and Objects” without even noticing which today has become “Object Oriented Enterprise Architecture” and the reason why things like this exist.

What I’m saying is people went to far with OOP in some languages and that’s where the hate comes from.

Have a look at the following video if you’re interested, take it with a grain of salt though.

YouTube - Object-Oriented Programming is Bad

//edit
I’d like to add that I do think that object orientation is very useful especially If you need to handle a multitude of similar entities. (Like for example actors in a game). I think the only problem with OOP is when in comes as the sole choice of doing things.


#7

Even the venerated OOP has its drawbacks.

Joe Armstrong, creator of Erlang, cites code reuse as a drawback for OOP (vs functional):

I think the lack of reusability comes in object-oriented languages, not functional languages. Because the problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.

If you have referentially transparent code, if you have pure functions — all the data comes in its input arguments and everything goes out and leave no state behind — it’s incredibly reusable.


#8

I’m not sure how he defines reusability but in Ruby there are lots of ways to create reusable code, inheritance, modules, etc…


#9

Inheritance is exactly what he’s talking about with the Gorilla-Jungle problem. It isn’t that reuse is impossible in Ruby - in fact, it’s much nicer than some other OO languages - but that it’s still more difficult and bulky than it needs to be. This isn’t even controversial, and in the Gang of Four’s Design Patterns, they even drive home the point that composition should be favored over inheritance. The OP’s link addresses Ruby in particular:

(An aside: some people argue “Ruby proves that it is possible to have a low-ceremony OOP language.” Nowadays most languages have drawn inspiration from multiple sources, and many languages are multi-paradigm, so when I attack an OOP language, I am attacking those parts of the language that draw ideas from the OOP tradition. As Paul Graham has pointed out, over the years, nearly all languages have borrowed more and more features from Lisp. My point is, the features that allow Ruby to be low-ceremony are drawn from non-OOP languages.)


#11

But is that what the author said? I didn’t pick up on any criticisms of other programmers.


#13

Here is one. Microserfs! OOP! Great, prophetic book. Or did you mean JPod? I didn’t read that one.


#14

I was referring to MIcroserfs - first time i heard of OOP myself
Used to love him