Classes: suggestions for improvement

Axel Rauschmayer axel at
Sun Jun 12 14:22:46 PDT 2011

I really like the proposal: it is very lightweight syntactic sugar. For example, it is not that radically different from Resig’s Simple Inheritance (whose "look" I like). The "super" keyword for calling overridden methods and chaining super-constructors and the "static" keyword for defining class properties are welcome additions. Especially "super" saves a lot of boilerplate code.

Minor suggestions for improvement:

(1) The syntax for private properties still is a bit clumsy, and @ feels like wasting a nice symbol, how about using instead of private(this).foo?

(2) "public" feels superfluous in class body and the word "public" does not really denote the opposite of "static".

(3) Is "static const" possible?

This is a bit farther out: There is a use case for having a superclass and 0 or more prototypes at the same time. The former is useful for constructor chaining, the latter could be used to implement poor man’s traits. Then the prototype chain would look like this:

subTypeInstance |> SubType.prototype |> Trait1 |> Trait 2 |> SuperType.prototype

Does anybody know what Brendan meant in this txjs talk with “Classes made it (Yay, I think? Why am I sad?)”? Is he ambivalent about the proposal? Is there anything he doesn’t like?


Dr. Axel Rauschmayer

axel at


More information about the es-discuss mailing list