[Grace-core] Dialect Design Proposal

Lex Spoon lex at lexspoon.org
Wed Nov 28 09:17:08 PST 2012


On Wed, Nov 28, 2012 at 6:42 AM, James Noble <kjx at ecs.vuw.ac.nz> wrote:
> and, in practice, Self had issues too. I know less about JS, but I
> don't think we'd want to emulate it either.

I've had occasion to learn quite a lot about JavaScript, and I don't
believe that JavaScript has anything Grace should emulate. I believe
the following summary is accurate and fair:

  Idiomatic JavaScript uses class-based inheritance.

Natively, JavaScript supports a form of prototype inheritance, but
it's not a cleanly (and intentionally) designed system like in Self.
Instead of every object having one or more parent objects to delegate
to, JavaScript objects have a "constructor" function which has an
prototype object, and prototype objects can be singly linked in a chain.
It's an adequate solution, but nobody seems to like it in practice.
Personally, I find it baroque and confusing.

In practice, the code that JavaScript developers write and maintain
uses some form of class-based inheritance layered on top of the
native mechanisms.  Dojo and ExtJS both have explicit support
for classes--the former using multiple inheritance similar to
Python and Scala. Furthermore, it has been announced that
the next version of the JavaScript spec will include syntactic
sugar for classes.

It seems that Self, even after all this time, is the
best exemplar for prototype-based inheritance.


Lex Spoon


More information about the Grace-core mailing list