Dec 5, 2012

Ember.js and CoffeeScript

Of all my favorite things about CoffeeScript, one of the less obvious is the way it has encouraged and inspired people to write their own AltJS languages. Naturally, many of these build upon CoffeeScript itself, in some cases extending it with just a feature or two. One well-known example is IcedCoffeeScript, but there are many others.

This week I came across one that I feel is worth a special mention: EmberScript, an extension of CoffeeScript created by Gordon Hempton, who blogs regularly about Ember.js.

I've been floating the idea of writing a book teaching Ember.js in CoffeeScript on the same interactive platform as my Backbone + CoffeeScript book. But it hadn't occurred to me to extend CoffeeScript for a better fit with Ember.js. I wrote Gordon to ask how he got the idea, and this was his reply:

As far as EmberScript is concerned, the idea started with an interest in Ember.js itself. Ember.js is divided into multiple modules, including what is essentially its own javascript-based object model and language runtime. I have also always been a big fan of CoffeeScript, but CoffeeScript has never been a perfect fit with Ember (e.g. CoffeeScript also has its notion of classes). EmberScript is an attempt to give Ember.js constructs first-class language support. Things like property bindings, observers, classes, and mixins are all supported directly within the language itself. Because EmberScript is also a compiled language, really cool things like property dependency inference are also possible! EmberScript is ember-infused CoffeeScript.

You can read more about how Gordon modified the CoffeeScript Redux compiler in his blog post.

Is this the first time a programming language has been forked to support the features of an application framework? Like everything else, I suspect it's been done before. Please leave a comment if you have an example.