class sugar

Axel Rauschmayer axel at
Sat Jun 4 13:59:17 PDT 2011

I am also one of those people who like prototypal inheritance and not out of ignorance: I have read my SICP and understand how the closure-based approach works.

Advantages of prototypal inheritance:

- Sharing data between instances and between types and subtypes.

- Clear separation of responsibility: The constructor adds instance-specific data, the prototype contains information that is shared between instances.

- Inheritance: Though clumsy, it can be done. The closure approach would be more complicated here (optional "self" parameter to which properties are added, but then you can’t use object literals, any more). This is where JS prototypal inheritance really needs help, even if it is just something as simple as YUI’s extend().

To truly appreciate the elegance of prototypal inheritance, I recommend the following paper:
“Organizing Programs Without Classes”, David Ungar, Craig Chambers, Bay-Wei Chang, and Urs Hölzle.

The challenge with prototypal inheritance in JavaScript is to get it right. But with a little syntactic sugar that wouldn’t be an issue.

Dr. Axel Rauschmayer

axel at


More information about the es-discuss mailing list