obsoleting the "new" keyword

Peter Michaux petermichaux at gmail.com
Wed Jan 14 10:51:49 PST 2009

On Wed, Jan 14, 2009 at 9:40 AM, Mark S. Miller <erights at google.com> wrote:
> On Wed, Jan 14, 2009 at 9:19 AM, Peter Michaux <petermichaux at gmail.com>
> wrote:
>> The requirement that JavaScript needed to look like Java has long been
>> lamented. One of the key "looks" was the "new" keyword.  Many people
>> don't like the use of the "new" keyword. Although "new" is here to
>> stay, could we obsolete it when using a class sugar?

I should have omitted "when using a class sugar". I'd like to see
"new" completely unnecessary.

> I agree. For *all* the desugaring of classes I've posted, the constructor is
> merely a function, not using "this", that constructs are returns a new
> instance. Thus, you get the same effect whether "new" is used on these or
> not. Both "Point(3, 5)" and "new Point(3, 5)" return the same thing.


Needing "new" makes some things unnecessarily bulky.

var pts = getRows().map(function(r) {return new Point(r);});

verses just

var pts = getRows().map(Point);

Unfortunately some of the ES constructors behave differently when
called without "new". This is a reasonably major problem with the
language, in my opinion. Is there anything that can be done about this


More information about the Es-discuss mailing list