Tuesday, February 26th, 2008

ECMAScript 4 Milestone 2 Released

Category: JavaScript

ECMAScript 4 M2 has been released and Francis Cheng has posted about the new version. M2 fully implements:

  • classes and interfaces
  • namespaces
  • pragmas
  • let, const, let-const
  • iterators
  • enumerability control
  • type expressions / definitions / annotations
  • runtime type checks (“standard mode”)
  • nullability
  • destructuring assignment
  • slice syntax
  • hashcode
  • catchalls
  • map & vector
  • date & time improvements
  • meta objects
  • static generics
  • string trim
  • typeof
  • globals
  • expression closures
  • name objects
  • type operators (is / to / cast / wrap)

Francis also posted about Vectors:

A new built-in class named Vector is proposed for ECMAScript edition 4. This class is similar to the Array class, but is designed for better performance, efficiency and error checking. Some interesting aspects of the Vector class:

  • vectors are dense;
  • vectors do bounds checking;
  • vectors can be fixed length;
  • vectors have type parameters;
  • vectors have the same methods as arrays.

David Tucker has posted about Colin Moock and his new lecture notes on the language changes that include:

  • Generic Functions: This functionality will add Java-style method overloading to ActionScript. A function must be defined with the keyword generic, but then mutliple methods (with different method signatures) can be used.
  • Iterators and Generators: Increased support for iterating over a series of values using a class defined iterator. Both of these items are very Python-like.
  • Proper Tail Calls: A function can properly call another function as its last operation – this adds increased support for recursion patterns.
  • New Number Types: byte, double, decimal (and the current generic ‘Number’ type would be removed)
  • Numeric Suffixes: As in Java, numeric literals will have suffixes to denote their specific numeric type.
  • Vector Type: As in Java, there will be a mono-typed array called Vector. Length can optionally be pre-defined at creation.
  • Record Type: Describes the details of an object – easier to create than a class. I believe it is dynamic – in that it has required values, but additional properties can be defined per instance.
  • Array Type: A type that describes what will be contained within an array. For example – you could say that you will have a 7-element array made up of Strings.
  • Union Types: A property (or argument) could be one of a list of types (as opposed to now where a property has to be of one type – or no type). This would give you the ability to have an argument that could be a String or XML – but nothing else.

ES4 keeps on chugging.

Posted by Dion Almaer at 8:12 am

4.1 rating from 25 votes


Comments feed TrackBack URI

Google Tech Talk:-

Upcoming Changes to JavaScript

Comment by bollywood — February 26, 2008

I for one would like ES4 not to get implemented at all. ECMAScript is good as is. Sure there are a few bugs in it, but why not just fix those instead of inventing a new language? I mean

dynamic class Pet{
function Pet(name){}
function getPetName(){}

this is ES4, it’s not what we know and love. The language is getting everything that’s been invented since the ES3 was released, in one way ECMAScript developers will be lucky they’ll have everything under the sun as far as language features go, but in other ways this might also turn out to be a curse.

There i said it. I don’t want ES4 hate, me call me an idiot what ever.

Comment by Zsolt — February 26, 2008

var myObject = (function(){

var myPrivateVar = “WTF do I need classes or namespaces for? I got anonymous functions!”;

return {

function getMyPrivateVar(){
return myPrivateVar;



Fix the language, don’t implement features that are absolutely NOT needed :(.

Comment by nea — February 26, 2008

Why can’t we just describe a common interface for browser languages? Then anybody could write their own browser language, specify it in their web pages, and all users willing to install the language plugin could run it. Then we’d have competition among languages. Instead we are getting languagezilla. You think comprehending fancy prototype code in ES3 is tricky? When John Resig pulls an all-nighter and writes up some wowza ES4 code, there will only be a handful of people on the *planet* that can understand how it works. Great!

Comment by JohnDeHope3 — February 26, 2008

yeah, well some of us would actually like to feel comfortable when developing large applications, instead of writing code that looks like it was written in basic – the early years.
and yes,
dynamic class Pet {}
is exactly what we know and love, and it is exactly what is missing from ES3.
_And_ yes, you can still develop whatever it is you develop, without using those features in ES4. It’s not like they will remove closures or anything like that.

Comment by urandom — February 26, 2008

I totally agree with Zsolt and nea, and I wrote the following article just after reading this announcement :

Comment by AdrienFriggeri — February 26, 2008

+1 urandom
I read your article btw and totally agree.
Prototype-based makes thing so easy, only it takes a while to get used to thinking out of the box when you’re coming from J2EE… Still I’m fine with the new ES4 as long as they don’t give up on the prototypes, closures and such goodies.

Comment by cruf — February 26, 2008

Deja Vu? I think this evolution has been completely justified. These same arguments have already been drug out in detail over and over and is starting to become tiresome….

See the detailed discussion here:


Comment by TNO — February 26, 2008

Zsolt, I quite agree with you. While some changes are helpful, like name spaces, others are totally uncalled for. Why have that generic function stuff for example?

I’m completely opposed to making a language so complex that the life of a maintainer becomes impossible. Every single feature will be used in the code he maintains and often in the worst possible way.

To me it looks like some Java guys had a look at JavaScript and decided to “improve” it. JavaScript is fine. It doesn’t need records, bytes, unions and all this heavy baggage.

Comment by Berend de Boer — February 27, 2008

They’re not actually taking anything away from javascript. Everything you do now you’ll still be able to do on ES4. The new syntax is optional. If you don’t like it, don’t use it.

I see a lot of useful things in the new syntax. The benefits of correctness and scalability will mean a lot when building larger javascript-based web applications.

Comment by Joeri — February 27, 2008

@Joeri, saying that the new syntax is optional is like saying: i know you have a car, but here’s a monster truck if you want you are free to use it.

Comment by Zsolt — February 27, 2008

I welcome features that will allow for faster client-side code and better type checking (when it is needed), but 2/3 of the proposed additions are *C*R*A*P*. They will do nothing but complicate the language, bog it down, and make it harder to troubleshoot.

I am not against Java in any way, but I agree with Berend: it looks like some Java guy (who does not understand the beauty of Javascript) tried to “improve” it.

Who devised these “necessary features”????

Comment by John Hann — February 27, 2008

Old news that goes over a lot of this:


This isn’t something some random guys pulled out their ass, some of the people on this committee include:
Douglas Crockford of Yahoo (http://javascript.crockford.com/javascript.html)
Brendan Eich of Mozilla (Creator of JavaScript) (http://weblogs.mozillazine.org/roadmap/)
Lars T Hansen of Adobe (http://www.ecmascript.org/es4/spec/evolutionary-programming-tutorial.pdf)
Chris Wilson of Microsoft (http://blogs.msdn.com/cwilso/)
Google, and others.

I for one have confidence in their ability to improve things (their differences aside). For those that don’t, well there IS a web page for it: http://www.ecmascript.org/community.php

Once again, no one is FORCING this on you to use. Each respective company is going to implement what they like and leave the rest (for example: http://ejohn.org/files/Adobe_position_on_ES4_features.pdf). Just breathe a sigh of relief that there is a standard being developed for this, and not some JavaScript vs JScript war from the Netscape days.

Comment by TNO — February 27, 2008

Leave a comment

You must be logged in to post a comment.