Even if I disagree in the conclusions, this is a well written article.
Some thoughts:
- JavaScript (and Python, for example) let you add dynamically stuff to objects. This has pro and cons, and it has a deep impact to the way an OOP system works. You may like it, or dislike, but it is as it s.
- Technically there is no problem with the JS OOP, what you complain is about is the lack of visibility modifiers or interfaces, which is loosely related to OOP. A C++ developer could complain that in Java there is no private inheritance.
- In my opinion the old private concept would be wrong in JS. It is not up to you to decide what can be accessed or not. It is the responsibility of the designer of an object to tell its users if a property/method was destined to be public or not. But not allowing the access to a property it is another thing. Language like Java have private fields, and then let you access private stuff through reflection... I think the python way is much more simpler: let's use an underscore _. Yes I know, in Java reflection also check security stuff and so on, but I am not criticizing Java, I am just telling that JS code is publicly accessible and so the strong private concept doesn't make much sense in a web context.
- Property procedures is something for people coming from C# or Java. The others never felt the need of that. In addition, as you correctly write in the article, you can always write set/get myProp(){}
- Interfaces is what I miss most, but since in JS there is not static typing, it make no sense having interfaces (may be contracts...). For those who likes types there is TypeScript, as you write at the end of the article.
- Your Shape example is a bit misleading. It explains well your points, but this is not the way we do stuff in JS. The idea is of feature-able objects. So there is no need to inherit from Shape. You just need to implement the feature (getArea() in the example). From this point of view, class Shape is meaningless. This is more powerful (and dangerous) than binding things to a class. In Java you need a lot of adapters (praying that the developers exposed a good interface). In JS you just implements the method(s) required. Again, pro and cons...
- About typos, a lot of editors will suggest the right word. But it is indeed one of the cons of being a dynamic language.
Thanks for your article!
I appreciated this part "... In the meantime, some people create the most creatively dangerous workarounds for private properties..".
Private means class private. Closures, for example, are class instance (or object) private. There are very different concepts.
For those who gets it: thanks for not having written bullxxit like those Knight s of the web…