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.

Print | posted @ Tuesday, November 13, 2007 3:21 AM

Comments on this entry:

Gravatar # re: ECMAScript 4 – Kitchen Sink Included
by Josh Stodola at 11/13/2007 2:38 PM

" 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!
  
Gravatar # re: ECMAScript 4 – Kitchen Sink Included
by Peter Bromberg at 11/14/2007 2:28 AM

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
  

Your comment:

Title:
Name:
Email:
Website:
 
Italic Underline Blockquote Hyperlink
 
 
Please add 2 and 5 and type the answer here: