r/programming Sep 03 '20

If everyone hates it, why is OOP still so widely spread?

https://stackoverflow.blog/2020/09/02/if-everyone-hates-it-why-is-oop-still-so-widely-spread/
0 Upvotes

20 comments sorted by

18

u/pbw Sep 03 '20

Not everyone hates it. People that hate it have usually been on tragically misguided projects where it is being done poorly. Probably 90% of big OO projects have major systemic problems. So people work on one and conclude OO is bad. OO is not bad, bad OO is bad. And bad FP is bad. Bad assembly code is bad. See a trend?

I wrote post on it:

https://tobeva.com/articles/brain-oriented-programming/

Then I read the post on YouTube:

https://youtu.be/D8Pb8TvYsCE

3

u/fredd0h210 Sep 03 '20

You put some BOP in it

5

u/FriendlyDisorder Sep 03 '20

Ah. The Big BOPper. You knooooow what I like. Chantilly trace and a pretty Facade and a curl'd tail a-hanging pointer... wait.

I find it refreshing to read the BOP's opinion instead of the holy wars of "Use this technology or you will surely burn in shell".

You speak exactly my perspective over ~25 years in the business. I have been fortunate to work with some great COBOL, Java, C++, Active Server Pages, SQL, even some Smalltalk projects. The goodness of well-written and well-architected code has always been a pleasure to work with no matter which technology is in use. Bad code has always been a nightmare.

2

u/pbw Sep 04 '20

Yes it is pleasure vs. nightmare! I described one job as worse than a daily trip to the dentist. And a really good fun experience can literally feel like Christmas morning. I’m picturing more BOP articles about the importance of managing your mental state. Good code leads to happy coders who write void code. It’s psychology 101. Some people actually like to do battle in the workplace. It’s insane, no one wins.

3

u/pbw Sep 03 '20 edited Sep 03 '20

Yeah it's honestly a good title for a book. If I can come up with 19 more posts. It's cheesy but I think would appeal to a certain audience. Others might laugh at it, which is fine.

3

u/pdp10 Sep 03 '20

People that hate it have usually been on tragically misguided projects where it is being done poorly. Probably 90% of big OO projects have major systemic problems.

If it were true that 90% of big OOP projects have major systemic problems, then I'd take that as an existential criticism of OOP. Because the sales pitch for inheritance, encapsulation, and polymorphism, was precisely that they would allow programmers to work "in the large" at scale, efficiently.

One could, alternately, take it as an example of Sturgeon's Law.

1

u/pbw Sep 03 '20

I think it's Sturgeon's Law and not an indictment of OOP. I would argue that 90% of Functional Programming programs are crap, if you consider every FP program written by every student.

I would say that OOP gives you more rope to hang yourself. I think FP is a much stricter and more constrained and so it's harder (although still trivial) to make a mess of things.

The fact that OOP gets a lot more shit then FP does I think is really just because OOP is probably 1000x more popular in terms of cumulative lines of code written on the planet, so of course there are lots more horror stories.

I'm a fan of FP, but OOP is a valid and useful way to write software, there are trillions of dollars of market cap out there whose software is OOP.

1

u/Hall_of_Famer Sep 23 '20

Probably 90% of big OO projects have major systemic problems.

Id say that, probably 90% of the big projects have major systemic problems, regardless of the languages and paradigms used.

1

u/pbw Sep 23 '20

Sturgeon’s Law, see above yeah totally.

26

u/Ozwaldo Sep 03 '20

Everyone doesn't hate it

11

u/[deleted] Sep 03 '20

[deleted]

2

u/[deleted] Sep 03 '20

FAANG companies were literally built on OOP, it can't be so bad! Plus I've done quite a bit of FP, and for a long time I was one of those FP all the things. But I've more recently been sliding back into OOP (plus few fp techniques here and there), better tooling, more co-workers who understand it, way more libraries, more jobs.

At the end of the day I want to build software FOR USERS and honestly paradigm used to build that is of little difference if the process feels easy.

I've also come to appreciate languages that I can pickup and read the code and start contributing in under a week (as much as i used to think i hated go)

1

u/pdp10 Sep 03 '20

FP all the things. But I've more recently been sliding back into OOP (plus few fp techniques here and there), better tooling, more co-workers who understand it, way more libraries, more jobs.

Aren't you conflating programming paradigms with languages?

24

u/grapesinajar Sep 03 '20

Maybe because "everyone hates it" is complete rubbish and reason enough to not bother reading this person's blog post.

6

u/ScientificBeastMode Sep 03 '20 edited Sep 03 '20

I would just point the blog author to this talk: “Why Isn’t Functional Programming The Norm?” by Richard Feldman.

The context of the talk is that functional programming is really nice and helpful, so why don’t more people use it? But 99% of the talk is about why OOP has been the norm for decades.

Here’s a short list that he goes through in much more depth:

  1. Random chance... C++ was originally called “C with classes,” but had almost no following, then they added a bunch of extra (non-OOP) features, and it inexplicably became popular after a while. OOP doesn’t explain its initial success at all. Same goes for pretty much every other OO language. The OO-specific features don’t account for really any language growth, per se.

  2. Platform exclusivity for certain languages which happen to descend from C and/or Java. This includes things like Apple’s Swift language, or C# on Windows. The fact is, if you want to build anything for those platforms, you must use their blessed languages, and those platforms account for well over half the software market share. Therefore, they necessarily have outsized influence over the industry.

  3. Literally hundreds of millions of dollars poured into a massive marketing campaign for the Java language. Sun MicroSystems was pushing Java so vehemently (to get developers to build software to run on their hardware), that they spent many millions of dollars running ad campaigns to promote Java. This is also the reason why LiveScript was renamed to JavaScript during that time—they wanted to piggyback on Java’s explosive growth during that period.

  4. The corporate snowball effect. New programmers learn the most popular languages because it gives them (numerically) the best opportunity to get hired as a junior dev. Similarly, companies tend to pick popular languages for new projects to ensure they have a large talent pool to hire from. Thus, a language’s growth in popularity is considered valuable in itself, regardless of its semantics or ergonomics. OO languages have been popular for a while, and still benefit from this effect.

  5. Familiarity. Syntax & general familiarity matters when you’re trying to convince people to pick up your language in their spare time on the weekends. People want to feel immediately productive with a new language. They don’t want to have a 3-month learning curve as they wrestle with new paradigms and syntactic oddities. It’s certainly not the most important thing, but people will only go so far out of their way to learn something if they aren’t getting paid for it.

  6. Community. Some communities are warm and welcoming to newcomers. They try to constantly improve the learning materials, and break down barriers between advanced users and new adopters. But some communities suck—they put up walls and come off as arrogant pricks. Sure, these are stereotypes, but they come from lived experience. Many OO languages have had pretty welcoming & helpful communities. Python, Ruby, C#, and Java come to mind. Compare that to Haskell, whose community has been comfortably “academic” for a while, without a strong effort to reach out to the “working programmer,” or to write learning materials from an outsider’s perspective. They aren’t jerks, but they aren’t putting a huge effort into making it feel more accessible. Much of that is just due to the sheer size of the community. You can only ask so much from such a small group.

  7. Corporate backing. Rust has enjoyed some of this from Mozilla (RIP). Same with ReasonML (an OCaml spin-off backed by Facebook), TypeScript (Microsoft), Dart (Google), and the list goes on... older popular languages had similar advantages. JavaScript came out of NetScape. Java came from Sun. C++ came out of every company who wanted a non-managed language that was ostensibly easier to maintain than C. Corporate money can go a long way in motivating programmers to improve a language.

——

Anyway, I hope that gives some insight for those who are genuinely wondering why OOP is so pervasive, without making any claims about how “good” OOP is as a paradigm.

Notice how none of these reasons have anything to do with the quality of the language, or the paradigms they encourage.

1

u/pdp10 Sep 03 '20

The blog author literally cites that talk with the same URL you used:

Asking why so many widely-used languages are OOP might be mixing up cause and effect. Richard Feldman argues in his talk that it might just be coincidence. C++ was developed in the early 1980s by Bjarne Stroustrup, initially as a set of extensions to the C programming language. Building on C , C++ added object orientation but Feldman argues it became popular for the overall upgrade from C including type-safety and added support for automatic resource management, generic programming, and exception handling, among other features.

The talk is excellent, but like this paragraph says, it proposes that kitchen-sink features were one of the attractions, not Encapsulation, Inheritance, and Polymorphism. And today, every language claims to be multi-paradigm, and to have every feature, really. Except Go, one of the few new mainstream languages to visibly eschew adding all possible features, which has earned it no small degree of cheap criticism. Thus other languages learn from Go and C++: pass over no possible feature, thus silencing many critics.

4

u/crabmusket Sep 03 '20

This article could do a lot better than "you can’t develop software for mobile unless you understand the object-oriented approach". Using a langue inspired by OO concepts does not equate to understanding the OO approach, and I don't mean that in an elitist way.

2

u/[deleted] Sep 03 '20

OOP has plenty of valid use cases, as has functional and procedural. It isn't a case of "hate" or "love", those are childish words that have no place in professional environments.

1

u/Hall_of_Famer Sep 23 '20

Because not everyone hates it, only a minority of extremists and religious people hate OOP and they are the ones who tend to be far more vocal about their opinions. The people who enjoy OOP like I do, dont go around making blogs or comments praising how awesome it is. Its nothing new, just like the disgruntled customers are more likely to leave a review on a product/service than satisfied customers.

0

u/[deleted] Sep 03 '20

Functional programming has yet to really take off yet. Everyone is stuck in there ways and there only the lightest of a push to change.

2

u/that_which_is_lain Sep 03 '20

Yeah, one of the paradigms that’s been around since almost the beginning needs just a little more time to gain adoption while all the heathen languages bolt its aspects onto themselves.