Classical inheritance is obsolete
dmitry.soshnikov at gmail.com
Sun Jun 30 19:50:17 PDT 2013
On Sun, Jun 30, 2013 at 10:41 AM, Brendan Eich <brendan at mozilla.com> wrote:
> [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.
> 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.
Exactly. In fact, JS has classes for years (w/o sugar), as well as Python
is prototype/delegation-based (w/ classes sugar).
>From this perspective, classes themselves can be classified (long time ago
I created this quick cheat sheet for that:
https://gist.github.com/DmitrySoshnikov/977034; became a bit lazy at that
time for a full article for this, although had written before a good long
analysis explaining why JS being different, "is not that different", and
can be considered as class-based, as well as Python/Ruby are
delegation-based. Interested may find it on my site).
A class is just a code reuse pattern, the pattern has pros and cons. A
class is not the "class" keyword in a language. And even not the ability to
create classes using this keyword. And even not the static shapes of
created instances (see the "static second-class classes" as Java's). It's
just the ability to code in a classified code reuse: i.e. create instances
by the template. And this ability was here for years with
"constructor+prototype" pair. This spec will only add a bit of sugar. The
same as in Python which is considered as a class-based.
An important note: this sugar (and exactly the "sugar" as a slang
definition for abstraction matters) will give the ability for newcomers not
even know about the prototypes (and it's good). Which in this case will
just become as an "implementation detail".
P.S.: although, that mentioned, this topic is better discussed on JS forums.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss