ECMAScript 4 – Kitchen Sink Included

Tuesday, November 13, 2007

Ajaxian linked to a reference implementation of ECMAScript 4 today. ECMAScript 4 (a.k.a JavaScript) is still a work in progress. When the work is finished, the new standard will be the first major update to the language since 1999.

The language overview whitepaper is 40 pages of ambition – iterators, pragmas, packages, namespaces, serialization, generics, annotations, non-nullable variables - and the list goes on.

Here is some code I was toying with:


interface Printable {
    function print()
}

class Point implements Printable {

    
static var name = "Point class";

    
private var _x : int;
    
private var _y : int;

    function get x() {
return _x; }
    function set x(value:
int) { _x = value; }
    function get y() {
return _y; }
    function set y(value:
int) { _y = value; }

    function print()
    {
        intrinsic::print(
this.toJSONString());        
    }
}

Here is the code running in the reference implementation:

PS> .\es4
>> intrinsic::load('Point.es4')
>> var p = new Point();
>> p.x = 10;
10
>> p.y = 15;
15

Note that the following lines will create errors:

>> p.foo = "error: cannot add property to a non-dynamic object";
>> p.x = "error: incompatible types";

Wow! This is not the small, dynamic language that I've grown fond of this year. JavaScript is everywhere now – and I wonder how long it will take the various implementations to work out all the kinks in this standard.

ECMAScript is going from 0 to C++++ in a single release.


Comments
Josh Stodola Tuesday, November 13, 2007
" I wonder how long it will take the various implementations to work out all the kinks in this standard. "

Word. I have been thinking the same thing for years.

I am pretty excited about this!
Peter Bromberg Wednesday, November 14, 2007
Good Post, Scott. Javascript is, well -- ubiquitous. So, it's about time. Let's see how well everybody syncs up to implement it in a non-political, "greater good" way...
Pete
Comments are now closed.
by K. Scott Allen K.Scott Allen
My Pluralsight Courses
The Podcast!