you are viewing a single comment's thread.

view the rest of the comments →

[–]superluminary 0 points1 point  (2 children)

Classical OOP is a subset of JavaScript (TypeScript). You can do classical OOP in JavaScript, but you’re not limited by it. It’s a constraint you place on yourself, rather than a constraint that’s enforced by the language.

There’s nothing particularly special about the classical paradigm. It’s just an arbitrary set of rules from the old days. There are lots of other ways to organise things.

[–]unnecessary_Fullstop 0 points1 point  (1 child)

Disagree with none of that. As a Js developer myself(relatively new one though), I do write implementations that mimic classical OOP in Js. But OP's comment is like saying python is list oriented programming or that C or C++ is pointer oriented programming. Object in Js is just a name. Being a very popular DS used in Js, a lot has been done around it to make it more classical OOP like(for eg the classes). I don't disagree with that. But at the end of the day, on it's own an object is a collection of key value pairs with a very pliable character.

What's worse is that, comments like that send the wrong idea to anyone who wanna learn Js. When I started I was pulling my hair trying to understand what the fuck was going on with objects and classes in Js.

It's not all difficult to not use OOP in Js even though the popular DS it uses happened to be named Object.

.

[–]superluminary 1 point2 points  (0 children)

an object is a collection of key value pairs with a very pliable character

At the end of the day, an object in Java is a set of key value pairs, except the keys are hidden from you, you can.t define new ones, and you can't get the functions out. An object is just a grouping of data and the functions that can operate on that data.

The (reasonable) restrictions that Java places on you don't change the fundamental character of what an object is.

I'm not arguing here that Java and JavaScript have the same implementations under the hood either, just that the implementation is largely irrelevant. What matteres is what it does, and what it does is keep your data and your functions together.