JavaScript - Advantages and Disadvantages of Using Transpilers

javascript

// Advantages/disadvantages of writing JavaScript code in a language that 
// compiles to JavaScript:

The TypeScript compiler considers regular JavaScript code to be completely valid; 
but adds new features such as type annotations, classes and interfaces. All of 
that is stripped out at compile time to generate readable code, ready to be used 
on the browser. Some of those added features are planned for the next version of 
ECMAScript and the TypeScript team is trying to implement them in a way that 
respects the future standard. As web browsers progress in their support for 
ECMAScript 6, we may see TypeScript’s implementation fade out in favor of the 
standard.

JavaScript supersets are particularly interesting to those who are already 
familiar and comfortable with that language. They don’t try to hide JavaScript; 
but merely add syntactic sugar in the form of new keywords and constructs. As a 
result, it’s fairly easy to look at the compiled code and relate it to the 
original source, which eases debugging.

Other developers think that JavaScript is beyond fixing; but since there is no 
other choice right now, they’ll put up with it by hiding it behind a new 
language, one which suits them best. The motivations are varied and consequently 
the proposed solutions are varied as well.

It seems that one of the main motivations behind it is to get rid of JavaScript’s 
C-like syntax; some people apparently dislike curly braces and semicolons very 
much. From what I’ve read, CoffeeScript is inspired by Ruby, Python and Haskell.

So, if CoffeeScript or TypeScript ease your pain points, use it.  See
http://buildnewgames.com/compiling-to-javascript/ for more details.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License