Echo JS 0.11.0

<~>
naugtur 1400 days ago. link 1 point
The article describes a way to implement classical OOP in JavaScript using only features of the language available prior to ES5

Oh no, not again. :(
I see Author put lots of effort in building this and writing an article and I always feel for them. Implementing the old OOP in JavaScript is always time consuming and rewarding(at first). And a dead end.

Douglas Crockford did it over 10 years ago and regretted afterwards. Just one of the quotations: "I now see my early attempts to support the classical model in JavaScript as a mistake." 

The idea presented in the article will not evolve to a full classical OOP with classes and inheritance. And if it tries - it will most certainly fail with some unexpected behavior emerging or tons of crazy/scary boilerplate.

The way private variables are declared in the article defends any attempt at making the classical inheritance as far as I know. I tried to make private (as inside a closure) variables work well with inheritance and it's just not what JavaScript was created to do. See: https://github.com/naugtur/extendable-module
In my implementation the descendant objects would call inherited methods to modify variables in different objects instead of just themselves.

If there was a reasonable way around it, I bet it would already be insanely popular.


So, to the author of the article, and anybody who actually considers using the code from there:

Please take a look at new features in ECMA standards, they're being created to suit your needs. And they're developed by the best JS specialists there are.

Check out:
Object.create from ES5
Classes and modules in ES6
Web Components
Metaprogramming in ES6 - proxies (Proxy.create)


JavaScript is really powerful and expressive. Don't try to put it in the OOP straitjacket.

Replies