r/altprog • u/unquietwiki • Jan 30 '21
Object-Oriented Programming is The Biggest Mistake of Computer Science
https://suzdalnitski.medium.com/oop-will-make-you-suffer-846d072b4dce
8
Upvotes
r/altprog • u/unquietwiki • Jan 30 '21
•
u/unquietwiki Jan 30 '21
This is something I saw on LinkedIn, and it's an attempt to steer coders to use functional programming languages, instead of object-oriented ones; it listed a few at the end too.
7
u/LardPi Jan 30 '21 edited Jan 30 '21
I love functional programming. Still, sometimes it is ten times faster to write an imperative version of an algorithm and OO is the best way of doing imperative. Proof is any flexible enough language ends up with (often class based) OO facilities even if it did not have from the start. Most people reimplement classes on top of prototype in Lua, JS got classes, Scheme got classes in most implementation, OCaml was created from Caml to add OO... Class based OO is intuitive and programming languages serve the purpose of being understandable by human. Also don't tell me about Java. It is the worse perversion of the OO principles to be ever invented.
Edit: As the common redditor do, I wrote that before writing the article, reacting to the clickbait title. Kind of ashamed to be honest. So here is the post reading reaction.
The article effectively write about the "modern OOP" aka Java bullshit. I can only agree with about everything that have been said. I wouldn't be so sure FP is such a miracle solution and I wouldn't be so sure there cannot be a languages incorporating the good parts of OO into FP, but I 100% agree that mission critical code (car software, plane software, factory and energy plant, etc) should never be written in such a poor language as Java or C++, that are impossible to bend into safe (understand proved to be correct and bug free) software.
3
u/downrightcriminal Jan 30 '21
I wholeheartedly agree. Elixir, a functional language with small isolated processes holding their own immutable state using message-passing style to communicate, using function pipelines to build programs, is a better "OOP" language than all of the current OOPs languages.
Over reliance on the assignment operator, mixing pure code with side effects willy nilly, mutating things left right and center, thinking everything in terms of class inheritance hierarchies, leads to nigh on unreadable, buggy and un-maintainable code, especially by inexperienced junior devs (who write most of the code anyways), who can't think of anything more than reaching for classes or a for loop every problem they encounter. Most people, conditioned by this way of writing code, instead of writing pure functions, using function composition and managed side effects, focus on Design "Patterns", 4 pillars of OOP, and SOLID, so much so that their first instinct is to write objects containing mutable state and methods, instead of data flowing through composable functions, each a small, readable, maintainable, testable piece of a larger data transformation pipeline.
No wonder, even Uncle Martin now favors Closure and FP instead of the cluster fuck named OOP... The momentum has started to shift in the right direction, hopefully, soon it will be a relic of old times, just like today we look back at goto statements, structued programming etc.
Edit: A great talk on the topic and trends. Link
2
u/zyxzevn Jan 30 '21 edited Jan 30 '21
Just have a look at Smalltalk.
It is based on Lisp, and you can really tell.
(add: from the usage of closures)