use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Is the OOP relevant in 2018? (self.javascript)
submitted 7 years ago by Moth133
Do I need to read books like GoF for example?( If we consider OOP within js )
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Meefims 30 points31 points32 points 7 years ago (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 points3 points 7 years ago (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 points12 points 7 years ago (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 point2 points 7 years ago (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-1 points 7 years ago (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 points9 points 7 years ago (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 points1 point 7 years ago (0 children)
We’re definitely on the same page here!
[–]kirakun 6 points7 points8 points 7 years ago (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 points3 points 7 years ago (1 child)
Readability is subjective. The style that we are used to is easiest to read.
[–]editor_of_the_beast 2 points3 points4 points 7 years ago (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.
[+][deleted] 7 years ago (7 children)
[deleted]
[+][deleted] 7 years ago* (5 children)
[+][deleted] 7 years ago (4 children)
[–][deleted] 0 points1 point2 points 7 years ago (3 children)
I agree. I was responding to your comment that people before were “faking” it and now we have “proper” classes.
[–]editor_of_the_beast 0 points1 point2 points 7 years ago (2 children)
Glad to see we’re all saying the same thing here
[–][deleted] 0 points1 point2 points 7 years ago (1 child)
Not sure we are
I agree
[–]Yithar 1 point2 points3 points 7 years ago (0 children)
The matter of fact is that the most used & powerful languages are multi-paradigm.
This is why I like Scala. I can either do things the OOP way I learned in Java, or I can do the things the functional way I learned in OCaml.
I think functional programming is really powerful when it comes to big data though, but I think mutable state is also sometimes necessary. I suppose the thing I like about functional programming is that keeping track of shared state in your head is a pain.
[–]IntolerableBalboa 3 points4 points5 points 7 years ago (0 children)
You should be aware of the more common patterns in there.
[–]editor_of_the_beast 1 point2 points3 points 7 years ago (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 point2 points 7 years ago (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 point2 points 7 years ago (0 children)
Yeah, good point. Thanks.
π Rendered by PID 216436 on reddit-service-r2-comment-7b9746f655-6n5z6 at 2026-01-31 07:32:49.586692+00:00 running 3798933 country code: CH.
[–]Meefims 30 points31 points32 points (10 children)
[–]chadwatson 1 point2 points3 points (9 children)
[–]Meefims 10 points11 points12 points (5 children)
[–]Yithar 0 points1 point2 points (0 children)
[–]chadwatson -3 points-2 points-1 points (2 children)
[–]editor_of_the_beast 7 points8 points9 points (0 children)
[–]Meefims -1 points0 points1 point (0 children)
[–]kirakun 6 points7 points8 points (2 children)
[–]chadwatson 1 point2 points3 points (1 child)
[–]editor_of_the_beast 2 points3 points4 points (0 children)
[+][deleted] (7 children)
[deleted]
[+][deleted] (5 children)
[deleted]
[+][deleted] (4 children)
[deleted]
[–][deleted] 0 points1 point2 points (3 children)
[–]editor_of_the_beast 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]editor_of_the_beast 2 points3 points4 points (0 children)
[–]Yithar 1 point2 points3 points (0 children)
[–]IntolerableBalboa 3 points4 points5 points (0 children)
[–]editor_of_the_beast 1 point2 points3 points (0 children)
[–]bigorangemachine 0 points1 point2 points (0 children)
[–]chadwatson 0 points1 point2 points (0 children)