ECMAScript 4 – Kitchen Sink Included

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.

posted on Monday, November 12, 2007 10:21 PM by scott

Comments

Tuesday, November 13, 2007 6:38 AM by Josh Stodola

# re: ECMAScript 4 – Kitchen Sink Included

" 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!
Tuesday, November 13, 2007 6:28 PM by Peter Bromberg

# re: ECMAScript 4 – Kitchen Sink Included

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
Tuesday, November 13, 2007 8:59 PM by The Blog of Josh Stodola

# The next version of ECMAScript (version 4).

Determine if any Other Outside Element was Clicked with Javascript