Ask HN: Is there a clear, mature discussion of OOP/functional tradeoffs?

4 points by westoncb ↗ HN
Since getting into web development I've found myself regularly in contact with folks who take it for granted that OOP as a paradigm has proven itself a failure (typically with the attendant viewpoint that functional programming has proven itself to be superior).

My current perception is that it's primarily bandwagon mentality promoting the above viewpoint. For instance, I was reading an article purporting to explain what object-oriented programming 'really' is, and they cited as part of their motivation for bringing this up the wildly popular "Goodbye, Object Oriented Programming"[0]; and while the first article was not what I would call a particularly deep discussion of the nature of OOP, the popular article it referenced (with 44k upvotes) was just laughably unsophisticated, uninformed, and rhetoric-laden. Every point he put forward had such a simplistic rebuttal that I had to wonder if he was intentionally setting up straw-men or just didn't know better.

So now it's on my mind: "is this the sort of thing folks are reading which has given them the idea that OOP has been disproven as effective?"

Now I feel motivated to take a close look at the issue if there is a serious, well-informed dissection of the efficacy of OOP for modern developers. It would especially be valuable if instead of vaguely referring to inadequacies it also pointed out how alternate paradigms more successfully deal with specific points.

My current suspicion is, regarding OOP vs. functional: both can be used well or poorly, so a lot of it just comes down to the developer's ability to exploit their features—and the rest just depends on the domain you're trying to model. For instance, if that domain deals with a bunch of things that look and interact like objects, then OOP will probably be better; if it's mostly a complex, abstract computation, functional would be better.

[0] https://medium.com/@cscalfani/goodbye-object-oriented-programming-a59cda4c0e53

4 comments

[ 2.6 ms ] story [ 19.5 ms ] thread
Your last paragraph is pretty much where I stand. I'm not trying to fire a shot in a language war. I'm not trying to build a perfectly-architected Gang of Four masterpiece. I'm not trying to produce a mathematically beautiful perfectly-stateless category-theoretic treatise. I'm just trying to write a program that does something.

So I don't really care about FP ideology or OO ideology. I'll pick the tools that best let me get my work done. If that offends purists, that's their problem.

As to your actual question, a reasonable, unbiased discussion of tradeoffs... sorry, no, I don't have one.

Yeah, I think our thinking is pretty similar. I think OOP is very natural fit for thinking about lots of things, and I think there are some great ideas that have come out of the functional paradigm. I still prefer to use a language that has OO organizational structures, but I definitely feel some pain if I can't have first class functions. I also value the idea of functional purity and whenever possible I'll write my functions so they're pure—but I don't adhere super strictly unless in a part of the program that critically needs it. Same with immutability.
I was only introduced to FP 6 months ago, and I'm no expert on OOP either. Functional Thinking by Neal Ford compares the two (of course it favors FP). Should be a good piece to the puzzle, though, at least worth skimming it.

My opinion is that things like purity, immutability, type checking, and other FP characteristics are incredibly helpful, and they make me write code with fewer bugs.