Kevin Smith wrote:
Rather than abuse your inbox, I published this as a blog entry:
http://blog.khs4473.com/2012/03/using-object-literals-as-classes.html
Summary: It has been suggested that extended object literals can be
used to define class-like abstractions, and that consequently class
syntax is not necessary. I analyze the implications from the point of
view of a library developer.
Comments?
I've got a slightly different POV.
Yes, in a perfect world, there is no need for class constructs. All
people coming to ES learn how great and powerful it is to have the
prototypal inheritance which lets you do everything you did before and
many more.
I cherish this power and simplicity.
But, in the real world, everyone (except for the little percentage of
the ones willing to learn and go deeper) begin to rant "where are the
classes" and then painfully create some "library for OO in Javascript".
I _don't_ want to meat these all over. ES is fine as it is.
And to stop this "class library" proliferation (and creating code that
is much more mutually readable) one should add class constructs into the
language. But to make such construct well-blended into the language and
its prototypal nature.
First thing is, if it performs well for at least 80% of the common
cases, people will use it rather than "better, truer, real classy from
[inseet your own] library".
And second, it is not a tragedy if such classes "leak". I would even
tell it is a positive thing. If native ES.next classes are good enough
to describe class concept, but at the same time slowly learn the
must-have-classes developers that classes are nothing more than a
decoration based on the more basic elements of the language, they slowly
adopt it, step by step (singleton is probably the first to die in this
battle ;-) ).
I, personally, would live perfectly fine without class. A little more
than is already in proposals (<| for declarations; separation of
parallel hierearchy from single hierarchy) will suffice for me.
But there are different, above-mentioned reasons why native class is a
very good idea (of course, not a heavy implementation that bring
something another beyond the rich language of ES.next object literals;
but that fear could be probably buried - it seems heavy classes are not
going in).
kevin
Herby
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss