/ javascript

Should You learn CoffeeScript, TypeScript or Dart?

Some time ago, I answered the following question on Quora, and apparently, it became really popular. I was positively surprised by people's reaction, and decided to repost my answer here.

Read Preslav Rachev's answer to Should I learn CoffeeScript, TypeScript or Dart? on Quora

What follows is the (unedited) content of my answer. Feel free to vote for it, or share a comment.

You don't mention your level of experience with JavaScript itself. My general advice to you is: try to get into the nitty-gritty details of JavaScript, before you try any superset language. IMHO, languages that compile down to JavaScript are supposed to improve your productivity, but not replace it altogether.

Coming from ActionScript 3 myself, in 2011, I plunged into heavy-duty JS, by writing Haxe code, which I later compiled to JS. Everything went well, until some low-level code didn't execute the way it should. Then, hell broke loose. To find my way in the JS code spilled out by the Haxe compiler, I had to sit down and learn everything I knew about JS from scratch, up to the tiniest detail. Once I went through all that, I gradually learned to live with and love vanilla-JS.

Having said that, if you want to use a superset language, then let it be an ECMA-script compatible superset of JS. Like the others already pointed out, TypeScript is the closest superset to vanilla-JS. It uses JavaScript's object model and only adds on top, which helps you make the best use of both worlds. CoffeScript intends to do the same, naming itself a "syntactic sugar" language, but with a slightly different syntax. I have not worked with Dart so far, but from what I've been reading, it operates on a much higher level. Similar to Haxe, Dart code gets compiled down to JavaScript, but there is no direct way to interoperate with other JS libraries; you have to use a specific library for that. Unlike in TypeScript and CoffeeScript, JavaScript code is not a direct subset of Dart.

The second concern you have to keep in mind is why those supersets and higher-level languages were created in the first place. All of them were created with the idea of making JS a little bit more pleasant to certain types of programmers. Haxe was created with the ActionScript community in mind, Dart for the Java/Go community, TypeScript for the .Net world, and CoffeeScript by Ruby programmers, for Ruby/Python programmers. Perhaps, you'd like to choose a language that fits a particular backend technology that you or your team maybe working with.