prototype focus

Axel Rauschmayer axel at
Fri Jul 1 02:10:06 PDT 2011

> I don't think
> JavaScript has ever been far from its prototype roots especially if
> the programmer shifts to thinking about a prototype object instead of
> thinking about a functions prototype property.

That is basically the point that the proposal tries to make. Have you taken a look at the library code? It is very short and not a radical overhaul.

Note how below, there is always an extra "prototype" in there with constructor functions.

Super-calls (there will be syntactic sugar for this):
- Constructor functions:
- PAC:

- Constructor functions: Subclass.prototype = Object.create(Superclass.prototype)
- PAC: let Subclass = Object.create(Superclass)

Instanceof (internally):
- Constructor functions: o instanceof C === C.prototype.isPrototypeOf(o)
- PAC: o instanceof C === C.isPrototypeOf(o)

>> Problems that both prototypes-as-classes (PAC) and class literals (CL) are
>> trying to solve are:
>> - Subclassing is hard and not directly supported by the language: connecting
>> prototypes, chaining constructors, super-references.
> Object.getPrototypeOf(this) is pretty long.

See above.

> It seems to me that perhaps the PaC drifted too far or perhaps started
> too far from what JavaScript has already. If the idea is to shift the
> focus more towards prototypes, then starting from something like what
> I've written and adding "super" syntax would be more consistent with
> what JavaScript already has.

“too far from what JavaScript has already” is very vague. How so? With class literals, your code will look like PAC, anyway. Have you taken a look at Sect. 3? Do you agree that the mentioned conceptual simplifications hold?

I find Brendan’s anti-PAC argument much more convincing: that all people might find it more natural to think in terms of constructors than in terms of prototypes. If that is the case then PAC would be a bad idea. The other convincing anti-PAC argument is that it is a bad idea to have two class mechanisms.

Dr. Axel Rauschmayer

axel at


More information about the es-discuss mailing list