JavaScript Compiling and Transpiling

Become a Subscriber

It’s a bastard of a language. That’s why so many people try to create a new daddy for it and compile down to support the bastard child. -Unicorn’s Clayton McIlrath

JavaScript was born in May of 1995 with the given name Mocha. In the same year, the infant language was renamed LiveScript (September of 1995) and renamed again to JavaScript (December 1995) after Java, the cool kid who lived down the street.

JavaScript was adopted over the course of 1996 and 1997 by the European Computer Manufacturers Association (ECMA). ECMA loved JavaScript so much that they created a standard specification called ECMAScript so that anyone could have their very own little JavaScript languages and implementations. ECMA wanted what was best for JavaScript and its cousins, so the standard was expanded with ECMAScript 2 in 1998 and ECMAScript 3 in 1999, which is what we think about when we talk about JavaScript today.

Today, JavaScript is implementing ECMAScript 5 with ECMAScript 6 finalized and due for official release in June. Cute little JavaScript is growing up, adopting new syntax that’s reminiscent of traditional object oriented programming.

JavaScript is so popular that other languages want to be JavaScript. When a language is similar enough, a little make-up and an outfit change is all it takes to transform into JavaScript, aka transpiling. With some languages, plastic surgery and CGI are required for a successful impersonation of JavaScript, aka compiling.

Ruby can be compiled directly to JavaScript using compilers such as Opal and rb2js. Rails ships with CoffeeScript by default, and CoffeeScript transpiles into JavaScript. CoffeeScript is like JavaScript using simplified syntax. CoffeeScript is essentially identical to JavaScript, making the transformation very simple. It’s common to use CoffeeScript in rails applications instead of JavaScript.

Go can be transpiled to JavaScript with GopherJS though that it might be more accurate to call that compiling. JavaScript used with Node.js has some shared use-cases with Go, but there are a lot of gaps between those communities and intended uses of those languages.

At Unicorn, we dream about the day that Swift can be used for the web, but right now there is no way established way to compile from Swift to JavaScript. There are some shared ideals between the Swift and modern JavaScript communities, so it is bound to happen soon. For now, there is an experimental Swift to JavaScript transpiler project called swift2js which might lead the way.

The popularity of Angular and the coming of Angular 2 are influencing the modernization of JavaScript. Angular 2 is being designed around the forthcoming ECMAScript 6 standard for JavaScript, being built on TypeScript. Angular 2 being built on TypeScript is aiming for where the puck is going rather than where it is today, and transpiling to browser-compliant JavaScript is a necessary added step for Angular 2 development at this time.

JavaScript has become more important and influential than originally intended. Like it or not, compiling or transpiling into JavaScript is necessary as it is has become a tremendously popular standard and common denominator of web development. Luckily, there are a growing set of options for most every language and platform to leverage JavaScript’s central role.