JavaScript 2

After all discussions about the NBL and all surrounding issues, I realized I haven’t actually looked at what JavaScript 2/ECMAScript 4 will contain. I decided to do some research. What I found was mostly very old (2 years or so), but very enticing. If only half of it comes true, JS2 will be a power house. Of course, the C inspired JS syntax is still kind of repugnant, and it’s hard to see any kind of general purpose macro facility working on it. Pattern matching is the only reasonable way of getting macros in there, me thinks, and that just doesn’t pack the same power.

But still, there are seriously nice things there:

  • Classes (the classic kind), packages and namespaces
  • Destructuring
  • Generators and iterators
  • A real numeric tower
  • Optional static typing

The end result is that JS2 will look much more like Java, but pack greater power in many ways. I wouldn’t say that I agree about JS2 being the NBL, but we’re still talking some nice innovation here.

8 Comments, Comment or Ping

  1. Debasish

    Hi Ola -

    Introducing class based models in JS2 means moving away from the prototype based model. Do u think this is desirable ?

    - Debasish

    September 10th, 2007

  2. Ola Bini

    Debasish: Actually, the proposal for a class based model in JS2 is based on skinning, while still retaining the prototype based system beneath the covers, so you don’t lose anything.

    Prototyped object systems are quite cool, but on the other hand I’m not sure JS needs it… We’ll see.

    September 10th, 2007

  3. Swaroop C H

    Hi ola,

    The latest spec is at /doku.php?id=spec:spec

    – Swaroop

    September 11th, 2007

  4. Steve

    Take a look at Adobe Flex. They have implemented JS2. I like the E4X support, this is really what XML processing should be like in Java!

    September 11th, 2007

  5. jherber

    ola, have you looked at tamarin vm at all?


    because it was built from the ground up for ecma script, i.e. a dynamic language, i often wonder if it was a suitable option for targeting than the jvm.

    September 17th, 2007

  6. Christophe Grand

    Firefox 2.0 already has generators, iterators, array comprehensions, getters/setters and destructured assignements. See /en/docs/New_in_JavaScript_1.7.

    September 27th, 2007

  7. seo toolsz896sf

    hydroponics can increase your yield by 40% see what nasa is doing on mars.
    This hydroponic gardening site will show you the latest and greatest

    October 10th, 2007

  8. Vlad Didenko

    It is all would be exciting, however the ES4 plans are severely shattered: /pipermail/es-discuss/2008-August/003400.html

    December 3rd, 2008

Reply to “JavaScript 2”