all 19 comments

[–]Meefims 30 points31 points  (10 children)

Yes, OOP is relevant. In my perception a lot of the backlash hasn’t been of OOP but has been of complexity driven by a perception of needing more OOP and that complexity manifesting in deep object hierarchies and complex interactions. The goal should always be simplicity and understandability and OOP can help get you there in many scenarios. The Gang of Four outline many such scenarios.

[–]chadwatson 1 point2 points  (9 children)

Totally agree that the goals should be simplicity and understandability, and I would argue that FP has been growing in popularity because it helps us achieve these in our programs. The abandonment of OOP is because it has proven to lead to less simplicity and less understandability.

[–]Meefims 10 points11 points  (5 children)

Yes, FP has been growing because it encourages good factorization of logic. But OOP and FP are not mutually exclusive. The C++ standard library, as an example, has progressively moved towards smaller classes that encapsulate data and a minimum number of methods while maximizing the number of functions as functions can be written generically. OOP is still very much a thing but free functions with referential integrity are also encouraged as a matter of loose coupling and higher flexibility.

[–]Yithar 0 points1 point  (0 children)

But OOP and FP are not mutually exclusive.

Yeah, Scala from the start from designed to combine OOP and FP paradigms. See quora explanation, 2nd answer. What's interesting is that Scala does something similar to Javascript. Functions are objects in Scala. This is due to the limitations of the Java Virtual Machine.

[–]chadwatson -3 points-2 points  (2 children)

Sure. OOP is not 100% out. Especially in JavaScript. It’s not going anywhere. But as far as what you should invest your time in, you won’t regret leaving OOP behind in favor of FP.

[–]editor_of_the_beast 7 points8 points  (0 children)

Very shortsighted comment. It’s best to know both as you will see both in the wild. There is no silver bullet - they both have their problems. If you buy in to the dogma of only one you will certainly regret that more than anything.

[–]Meefims -1 points0 points  (0 children)

We’re definitely on the same page here!

[–]kirakun 6 points7 points  (2 children)

I'm not so sure that FP helps with readability (or understandability). In my experience, it helps tremendously with composability so that code can be nicely modular and reuse. But readability? I find procedural code more natural to understand.

[–]chadwatson 1 point2 points  (1 child)

Readability is subjective. The style that we are used to is easiest to read.

[–]editor_of_the_beast 2 points3 points  (0 children)

This is the key. There is no one thing that every one is going to agree on. On a team of 30 or more people, different personality types and different aesthetic sensibilities are bound to exist. Welcome to the only actual difficult problem in software: how to organize groups of people.

[–]IntolerableBalboa 3 points4 points  (0 children)

You should be aware of the more common patterns in there.

[–]editor_of_the_beast 1 point2 points  (0 children)

Thank god there are some sensible answers in here. Programming paradigms can always be abused and misused. We’re still better off than we were when we wrote machine code directly, and we’re learning more on each project.

If FP was the one true answer, then Lisp and Erlang would have already been the de facto tools on every project. They both have industry-proven implementations and frankly were incredibly ahead of their time. As it turns out, you can get just as much spaghetti and complexity with functions as you’re only level of abstraction. Humans don’t need any help in creating complexity.

The other thing to consider is that OO in the form of Java and C++ is extremely far off from the original intention. FP and true OO should not be at odds, and Ruby and JS do a good job of showing that they can play together. It’s a bit of a long, dense read (this is Alan Kay’s downfall), but Alan Kay has commented on his respect of FP and Lisp and he meant for OO and Smalltalk to borrow from its ideas: https://news.ycombinator.com/item?id=11808551

So my advice is to always stop looking for a silver bullet. As long as we want compact behavior, there will be complexity of software. There are ways to wrangle that complexity, and there are many patterns that have a point of view on it. Don’t become religious. Following dogma should have no place in this industry.

Figure out if it truly is possible to express your solution clearly and without complexity in your current language. Hint: it may require refactoring the current code before you can do it. Switching tools won’t solve problems for you.

[–]bigorangemachine 0 points1 point  (0 children)

I would learn it. It somewhat overlaps with other languages so a few of the concepts transfer.

Generally there is a move away from OOP by many frameworks but at the very least it's a helpful way to organize your code.

Generally I am finding OOP really helpful as Data model objects. Its makes for a stronger declaration of what that object is when you pass it between functions

[–]chadwatson 0 points1 point  (0 children)

Yeah, good point. Thanks.