tirsdag den 10. juni 2008

Mascara is not for people who hate JavaScript

Mascara is not the only project which cross-compiles to JavaScript.
If you for some reason don't like JavaScript or ECMAScript 4, these project may be more to your liking:

Google Web Toolkit - compiles Java to Javascript
Script# - compiles C# to JavaScript
HotRuby - compiles and interprets Ruby in JavaScript
CoffeePie - compiles Python to JavaScript
haXe - compiles the Haxe language to JavaScript
JSC - compiles MSIL to JavaScript
...and probably numerous others.

These projects makes totally sense if you work in a pure-Java or pure-.Net environment, and don't really want to learn a new language just because you have to to some client-side programming. Or if you simply don't like to work with JavaScript.

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 incompatibilties are caused by differences in the DOM and CSS implementions, 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.

5 kommentarer:

Anonym sagde ...

The demo fails hard in Opera 9.5RC

This:
var y : int = 18.5;

Becomes this:
class="hiliteline" style="background-color:yellow;">

Anonym sagde ...

Congratulations for this nice project!

What is the license of the sources? I see that in the mascara.0.1.5.tar.gz archive, there isn't the source code for the es4translator package, is this intentional?

Olav Junker Kjær sagde ...

@anonymous(1): Thank you for the heads up! Since 9.5RC is still a pre-release, I will assume it is a bug in Opera :-) If it still fails in the release version (which seem to be close), I'll look into fixing it ASAP.

Olav Junker Kjær sagde ...

@anonymous(2): I am going to release the source at a later point. It needs some refactoring and cleanup before I dare to show it to the world :-)

The source is however intended to be available and easy to modify for users of the system. For example, everyone has their own favorite way to simulate classes using Classic JS - therefore it should be easy to change one code generation strategy for another. Also, some might want to experiment with macros or DSL's on top of the system. This should also be possible.

I choose Python partly because I wanted the system to be easy to modify. It would perhaps have been easier to develop using using ML (like the reference implementation), but far fewer users would be able to modify it for their own need.

Regarding the specific licence, I have still not decided, but I will post about it soon.

Subscribe to the blog if you want to be notified when more information is available!

Brendan Eich sagde ...

Hi Olav, very nice work -- looking forward to source release. I would be happy to help add generator support.

Could you mail me at brendan at mozilla.org please? I don't have your email and wanted to talk about something one on one. Thanks,

/be

This blog has moved to http://blog.mascaraengine.com. See you!

This blog is (was) for news, announcements and questions regarding the
Mascara ECMAScript 6 -> JavaScript translator.