Classical inheritance is obsolete
brendan at mozilla.com
Sun Jun 30 10:41:47 PDT 2013
[Fixing empty subject.]
Chris Ryan wrote:
> Do we need classes at all? In my opinion, given that the concept is
> implemented in a clear manner and it is possible to be powerful enough
> to be of use in favour of prototyping (and developing based on the
> prototypal concept instead), then yes, it would have my support.
> However, my major gripe with the current classes proposal (and in fact
> with a few other proposals too, but that's a different story) is that
> it's just syntactic sugar added for the sake of it - it doesn't add
> any sort of functionality that cannot be implemented another way with
> the current toolset, and this contraption will only add complexity and
> confusion to the language.
No. Complexity would come from adding new kernel semantics (what's left
when you boil away all the non-primitive forms). Yet you accuse us of
doing anything but adding new kernel semantics ("it's just syntactic
sugar"), so you're selling a contradiction here.
As for "confusion", manually implementing |super| and getting it right
is a confusing and error-prone process. In fact |super| is a case of a
(small) extension to kernel semantics in ES6, but this tiny
under-the-hood complexity produces a net savings by eliminating the
greater user-facing complexity inherent in hand-coding |super|.
Anyone who thinks |class| came from Java is not paying attention.
Python, Ruby, and other languages (such as CoffeeScript, inspired by
Ruby and JS with a bit of Python) have |class|, but they are dynamic.
What's in a name? It depends, I think, on what you were taught.
I get the sinking feeling that someone has had a bad time drinking too
much Java or C# OOP-booze and, in the manner of a reformed drunk, wants
us all to do things the hard way when making prototypal inheritance
patterns with constructors, static and prototype methods,
I observe that many other JS hackers have no such negative hangover-like
reaction, and on the contrary say they could use a little sugar, and
even a bit of the strong stuff (e.g., small kernel extensions such as
|super|) in the punch.
More information about the es-discuss