Classes: suggestions for improvement

felix felix8a at gmail.com
Tue Jun 14 13:34:43 PDT 2011


On Tue, Jun 14, 2011 at 13:21, Bob Nystrom <rnystrom at google.com> wrote:
> On Tue, Jun 14, 2011 at 1:05 PM, felix <felix8a at gmail.com> wrote:
>>
>> How about using "prototype" or "proto" as the keyword instead of "class"?
>>
>> It's a declaration of a prototypical object used to generate other
>> objects.
>>
>> "prototype" is already a familiar word to JS programmers; this is just
>> extending its use into a new but similar context.
>>
>> "prototype" has a looser, more script-y feel than "class".
>>
>> "prototype" has less baggage than "class"; JS is likely to be the only
>> prototypal-inheritance language that most programmers know.
>>
>> "proto Point { }" reads well in English, it's a proto-Point.
>
> I think that's been considered before. My complaint with it is that Point
> isn't a prototype. It's a constructor function whose .prototype property is
> the prototype. In other words, the object bound to the name Point isn't the
> prototypical point. It's a constructor/class-thing/type-object kind of
> thing. It owns the Point prototype, but isn't it itself.

Hm, by that argument "class" isn't a particularly good term either,
since the thing created is not a class, it's a thing that generates
objects that can be considered instances of a class.  Maybe something
like "factory" would be a better term then?


More information about the es-discuss mailing list