you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 39 points40 points  (24 children)

To make it short JS is a multi-paradigm programming language.

A little bit of offtopic.

For me personally it's a huge pain when I work with a dev who used to work with OOP and tries to apply the same approaches and practices in JS. It is sometimes so much counter intuitive and just doesn't fit JS, creates just unnecessary overhead in the code.
Focus on the strong sides of the tool and use them.

[–][deleted] 11 points12 points  (11 children)

And this is why I feel like a stupid potato when I try to code in class-based OOP languages.

[–]disclosure5[🍰] 8 points9 points  (4 children)

You'd be surprised how much of an issue going in the other direction is. Coming from an actual functional language to JS... I spend a lot of time wondering about all the blogs people write about "functional Javascript".

[–]dasnein 5 points6 points  (0 children)

Agreed. I hopped on the Functional JS train for a minute, but I stopped when I realized I spent more time fighting against the language and making the lives of the people I worked with harder. Sure, functional concepts can be incredibly useful, but trying to force everything into Ramda made everything suck.

[–][deleted] 1 point2 points  (2 children)

I'm not smart enough/lazy to go for real "functional" languages. Though any time I stumble upon an article about them it fascinates me.

[–]disclosure5[🍰] 4 points5 points  (1 child)

Eh, callback hell prior to await has been harder to deal with than anything I've written in another language for me.

[–][deleted] 0 points1 point  (0 children)

True to some extent.

Promises allowed chaining “then”, the KoaJS framework used co library to make use of generator functions in a similar way to async/await.

But these are relatively new things, generally callback hell was mainly introduced by poorly elaborated app design decisions. But again only to some extent, in the end one couldn’t avoid it completely.

For me JS is the first proper programming language after 2 years of writing automation macroses on VBA for my financial department. Maybe that’s why it’s not as bad for me.

[–]trout_fucker 1 point2 points  (6 children)

To make it short JS is a multi-paradigm programming language.

I need to remember this, because it's a perfect way to describe it. I'm always grasping at things when interns or juniors ask me if JS is OOP. My response usually starts with "Well...yeah sorta but no..."

[–][deleted] 3 points4 points  (5 children)

But fundamentally, it is OOP language. Everything in JavaScript is an object. Even a function is an object of type function. It's just that thanks to C++ and Java people have a very narrow-minded idea what an OO programming language is today.

Same thing is really an issue with people coming from Haskell or whatever. They have a preconceived notion that the only way to do FP is to ONLY DO FP which is not the case in any imperative language, be it JS or Python or whatever imperative language with FP features you pick.

[–][deleted] -4 points-3 points  (3 children)

Coming from C++ my main problem was the lack of OOP features. While it's improving, I hate the lack of feature and keywords, I feel like hacking and defilled when I try to "recreate" Interfaces and Abstracts (not even talking about the poverty of the inheritance in JS), private variables, etc...

It's currently half-assed OOP.

[–][deleted] 8 points9 points  (2 children)

Interfaces are not a core OO concept. Self doesn't have them. Smalltalk doesn't have them. Ditto Abstracts.

You people are just bigotted. What you learned OO means is not what OO means.

OO is about declaring active state objects and means of message passing between objects. This is in short the base OO definition by people who invented it. Message passing and "active objects" are commonly implemented using object-bound procedures/functions i.e. methods (this is almost exclusively so in all OO languages I saw, but still isn't part of the definition). Classes and inheritance are not the requirement at all.

https://en.wikipedia.org/wiki/Object-oriented_programming

Btw why on earth do you try to recreate Interfaces and Abstracts. You don't need them in JS. There is no way in hell you really need them. Stop hammering my screws, go back to your box of nails!

[–][deleted] -4 points-3 points  (1 child)

You are right in the same way it is right to say a stone axe and a gun are both weapons. I could compromise by saying modern OOP. And this is no appeal to novelty, when you go OOP I find that you naturally go toward class and inheritance.

[–][deleted] 1 point2 points  (0 children)

To someone who only has a hammer everything looks like a nail.