Building on Top of JavaScript

JavaScript is not going away. If you're a fan of the language or not, it's still the de-facto user interface language of world-scale development. We've seen attempts to supplant it fall by the wayside (e.g. Flash and Silverlight). Now things seem to be going the other way - treating JavaScript as a runtime. These solutions involve translating a higher-level language into plain-old JavaScript - usually on the server, for performance. For now, I'd just like to talk about CoffeeScript - and maybe follow up on Dart and TypeScript later. Disclaimer: I really like CoffeeScript - it removes a lot of the rough edges from a decent (if spartan) language.

CoffeeScript:

The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable and pretty-printed, passes through JavaScript Lint without warnings, will work in every JavaScript runtime, and tends to run as fast or faster than the equivalent handwritten JavaScript.

The thing that draws me to CoffeeScript is that it's not a whole new language with new paradigms on how to use it - it really is just JS, just not as ugly. It's white-space significant (which I've grown to like). "It's Just Javascript", so resulting JavaScript is pretty easy to mentally map to the source CoffeeScript while debugging. There are a lot of features like Classes, arrow operators replacing the 'function' key word, Loop Comprehensions (do you miss LINQ? think underscore), and a host of other useful things.

Where can you use CoffeeScript, and how? To learn about the language head to http://coffeescript.org. Then you can practice your chops at http://jsfiddle.net. I find http://js2coffee.org very nice for going back and forth between CS and JS.

When you're ready to start using CS in your app, there are a couple of options. If you're using Node.js - it's already built in! .

For Visual Studio, just grab the free Web Essentials extensions for 2012 or 2010. It allows you to edit CoffeeScript (in addition to some other interesting stuff).

It seems that most Web Development environments support it in one way or another - here's a plugin for Eclipse.

Next, I'll go over the other two (which are not "just JavaScript") - they bring heavier OOP concepts to the table.

Where do you stand on CoffeScript or compile-to-JS languages in general?