Tuesday, June 10th, 2008

Mascara: Putting lipstick on JavaScript?

Category: JavaScript


Mascara is the latest in a “Write code in X and translate it to JavaScript” system to be launched.

Mascara calls out systems like GWT, Script#, and HotRuby and says…

Mascara has a different approach, because we actually like JavaScript. The core of JavaScript is well-designed, powerful and flexible, and in many ways a more modern design than C# and Java. ECMAScript 4 is not a replacement for JavaScript, rather it is a set of powerful extensions to the base language, while still fully backwards compatible with classic JavaScript.

This means you can keep using all your existing JS-code, or gradually upgrade your code step-by-step to ES4. ES4 is actually specifically designed to allow gradual upgrade from classic JavaScript to ES4.

You can keep using your favorite JavaScript libraries like jQuery, Prototype or YUI and the immense amount of JavaScript code available on the web, while still making your own code more robust and structured by utilizing the ESMAScript 4 type verification and constructs like classes and namespaces.

JavaScript have gotten a reputation for incompatibilities across browsers. This is somewhat unfair, since JavaScript the language is quite consistent across browsers. The incompatibilities are caused by differences in the DOM and CSS implementations, which indeed are frustratingly inconsistent across browser. But that problem is not solvable at the language level, but rather at the library level, where jQuery or the alternatives will hide the browser incompatibilities for you.

So, if you like JavaScript, but want more of it, ECMAScript may be for you.

The generator is written in Python, and John Resig has a good writeup of the features:

  • Type verification
  • Classes and inheritance, constructors, super initializers
  • Static members
  • Type inference from initialization
  • Parameterized types, Map and Vector
  • Union types
  • Structural types
  • Getters/setters
  • Namespaces
  • Nullable types

Time to write JavaScript in JavaScript? Will this type of system be a way to start writing in JavaScript that has it run in older VMs?

Posted by Dion Almaer at 4:25 pm

3.4 rating from 25 votes


Comments feed TrackBack URI

Here’s his post to the ES4 mailing list:

Comment by TNO — June 10, 2008

Wow. That’s almost what I asked for the other day in a GWT discussion. I want a JavaScript compiler.

But what I really want out of it is the kind of optimizing that GWT does.

Comment by Nosredna — June 10, 2008

Nosredna: the short answer: “it’s hard”. A project was started a while back at the Dojo Foundation (it would work with any JavaScript code): http://dojotoolkit.org/2006/08/31/js-linker-dojo and http://ajaxian.com/archives/js-linker-in-dojo-toolkit for more info. Unfortunately, lack of interest/contributions have caused it to bitrot for the better part of two years.

Comment by Dylan Schiemann — June 11, 2008

Mascara is a cosmetic used to darken, thicken and define eyelashes. Putting mascara on your lips will throw an error

Comment by Gordon — June 11, 2008

@Gordon, you have too much knowledge about that… :)

Comment by PedroBatista — June 11, 2008

Funny that the tendency towards moving AWAY from JS is so huge now at all places…

Comment by polterguy — June 11, 2008

“…because we actually like JavaScript”

Wonderful quote! :-)

Comment by robnyman — June 11, 2008

Leave a comment

You must be logged in to post a comment.