Tuesday, December 4th, 2007

Upcoming Changes to the JavaScript Language

Category: JavaScript, Presentation

Waldemar Horwat and Pascal-Louis Perez gave a tech talk at Google where they walk us through the new features of ECMAScript ES4:

After eight years of work in the standards committee, JavaScript will soon get an update. We present the highlights and rationales of the proposed changes to JavaScript.

The fourth edition of the ECMAScript (JavaScript) language represents a significant evolution of the third edition language, which was standardized in 1999. ES4 is compatible with ES3 and adds important facilities for programming in the large (classes, interfaces, namespaces, packages, program units, optional type annotations, and optional static type checking and verification), evolutionary programming and scripting, data structure construction, control abstraction (proper tail calls, iterators, and generators), and introspection. Improved support for regular expressions and Unicode, richer libraries, and proper block scoping are also added.

The nice thing about this presentation is that you see a lot of examples of the new features such as packaging (namespace, package, programming unit) and a lot of talk on the changes with optional types.

Posted by Dion Almaer at 7:56 am
9 Comments

+++--
3.2 rating from 25 votes

9 Comments »

Comments feed TrackBack URI

I find this a little hart to listen to for an hour…

Comment by Kevinin — December 4, 2007

It is ok. I found some parts confusing, and why would you ever do that, or that is extremely stupid. Such as 10:34 with the 3 different forms of using let.

At 11:14, I also don’t understand the last example, with swap, as [a,b] does not have a variable name. Would it not be?
function swap( a:[a:*,b:*] ) { return [a[b], a[a]]; } as you have variable names, and defined the types…

With types, are they all final, or are they malleable/dynamic. So if I define a type, can I change it later, or add things to it as well? So I have: type Nums = [int,int,int]; Nums.push(int);

I also don’t understand why int and boolean are not nullable by default?

Parametrized Types is also confusing as seen on 25:08.

31:15 – 31:52 were also confusing. I don’t understand any usage for these…

The question about types of generic functions is a brilliant one. Wouldn’t a obvious and simple solution just be:
generic function func ( a:boolean ) { }
generic function func ( a:int ) { }
typeof func (int);

Yeah… If anyone can give some feedback to my ponders, I would be really thankful!

Comment by Benjamin \"balupton\" Lupton — December 4, 2007

Whoops, my last code example should be:
generic function func ( a:boolean ) : boolean { return a; }
generic function func ( a:int ) : int { return a; }
typeof func (int);

Comment by Benjamin \"balupton\" Lupton — December 4, 2007

I agree with benjamin on some things being extremely weird not useful at all. Also the guy giving the presentatoin was quite annoying to watch for an hour. Some interesting stuff though.

Comment by TommyMaintz — December 4, 2007

use strict;
ha-ha ))))

Comment by shabunc — December 5, 2007

They didn’t do so good a job of explaining the reasons for all of the language features. I’m sure there is a reason for every one of them, but stuff like let looks mostly pointless on the surface (why would you want to scope a variable to a block instead of a function?).

There are two things I really need from pure JS:
– static typing, but backwards compatible with legacy code
– better performance
I can assume static typing requires a bunch of language features to make it workable, but better performance if I understand correctly doesn’t require any language features, just a better VM.

The new class syntax is nice, but prototypes worked just fine once you figured them out. Generics I don’t care about.

Comment by Joeri — December 5, 2007

Horwat’s shirt was the bomb. I was waiting for my Flameco lesson.

Comment by Matt — December 5, 2007

Flamenco-

Comment by Matt — December 5, 2007

Joeri: better performance comes to untyped code in better VMs, but “best” (enemy of good, remember ;-) still will happen with ahead-of-time type information. Also, a point I’ve hammered on in my talks: classes cannot be simulated with prototypes and closures; you can still add properties to a closure; you can still spoof. Classes are an integrity device, a capability even (with private constructors).

The rationales for most of the changes are covered in the new documents at http://ecmascript.org, both the language overview, and especially the tutorial on evolutionary programming. Feedback on these docs, sent to the es4-discuss@mozilla.org list, is welcome.

/be

Comment by Brendan Eich — December 5, 2007

Leave a comment

You must be logged in to post a comment.