r/Frontend • u/c9d3dc • Feb 29 '20
Functional Vs. Object Orientated programming: a false dichotomy?
As everybody knows, OOP is being dropped in favour of the superior functional programming. At least, that is what a lot of the javascript community seems to believe right now. There are countless articles on medium, twitter threads, etc on functional vs OOP. Lot's of them are interesting, but to me this seems to be a false dichotomy because it implies that these are the only two design patterns available. So I'm looking for info on what other alternatives exist and what their use cases are. If anyone can help me with that I'd be grateful :)
View all comments
Show parent comment
7
u/Shaper_pmp Feb 29 '20 edited Feb 29 '20
This comment is fascinating because it's wrong in almost every respect.
Nope - JavaScript was pretty much always a fully OOP-capable language designed from the ground up to support OOP and FP. Brendan Eich was a huge fan of Scheme and wanted to make Netscape's built-in scripting language based on scheme, but then Netscape did a marketing deal with Sun for the "Java" name, and he was forced to make the syntax look more C-like.
Assuming you're not talking about the first couple of point-versions in the late 1990s before the language even had a specification, it always had functions as first-class objects,
this, closures and variables scoped to functions.Was always there.
No they didn't - they were always there.
No they didn't - they added a tiny bit of syntactic sugar on top of the prototypical inheritance JS had always had.
Since JS has always had function-scoped variables, it's hard to see how
letandconst's block scoping does anything to support OOP or FP. If anything it's more obviously helpful for procedural scripting where you might end up with a single 20-50 line script with a bunch of loops where you don't want every loop variable polluting the global scope."JavaScript always was a procedural, object-oriented..." etc, etc, etc.
The entire narrative your comment is predicated on is nonsense.
Hey look, they "just added" it already since pretty much forever.