re: Why JavaScript is an OOP Language (Even Though It Doesn't Have Classes) VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I agree, but the same is true for any language. You can write Java using only static functions and immutable objects, and you can write Haskell fun...
 

Yes, I think my biggest issue with this is the clickbait... It got me to read it because I initially thought "JavaScript's main draw is that it is a 'any paradigm' oriented language... let's see why marinbenc thinks it's an oop language", but I was let down because it's really just an analysis of how to use JS in a OO manner.

Many, MANY people make the mistake of calling it an OO language because its base element is an Object, which is understandably confusing. This is a great breakdown of how prototypal inheritance works and how it can be used in place of the traditional Class syntax from other languages/TypeScript/JS syntactic sugar. It would have been nice to see the other two pillars of OO addressed like Eljay-Adobe mentioned.

You could talk about things like using the module pattern for encapsulation(Revealing module specifically is very encapsulated, where you export/return only the public methods to a caller) and directly point to poolymorphism when talking about the animal/dog inheritance chain (The object IS A dog which IS An animal... polymorphic objects have 2 or more 'IS A' relationships. This is in opposition to composed objects which are 'HAS A' relationships like you might see in Functional programming. It's good to mention both paradigms.... because technically you can use both (and procedural too!) in one application in JavaScript, which is why so many people use the language for things other than web-dev.

Functional Programming in Java would be awkward and clumsy, probably with one super class that everything 'is' and just... bad code. Not as familiar with Haskell, but you would probably have to do similar language hacks to get OOP working in it.

In JavaScript, both just work, but the writer needs to understand what they are doing to keep it from becoming a mess if they use booth approaches equally in one application (and maybe... since engineering is a team sport... don't ever do this to your team-members haha), so it's good to contrast the two any time you're talking about how to do one or the other.

DISCLOSURE: Old guy. (Not making fun of Eljay... I just wanted to make an old guy joke at myself :D)

code of conduct - report abuse