Lesson 2. Transpiling with Babel
When new features are added to JavaScript, the browsers always have to play a game of catch-up. It takes time after an update to JavaScript’s specification before all modern browsers have everything fully implemented and supported. In order to use all of the features covered in this book, you’ll make use of the technique covered in this lesson: transpiling.
Transpile is a portmanteau of the words translate and compile. Compilers typically compile a written programming language into incomprehensible[1] machine code. A transpiler is a special kind of compiler that translates from the source code of one programming language to the source code of another.
1To a human, anyway.
Transpilers have been around for some time, but they exploded onto the JavaScript scene in 2009 with the introduction of CoffeeScript (http://coffeescript.org). CoffeeScript is a compile-to-JavaScript language created by Jeremy Ashkenas, who is also known for creating the popular JavaScript libraries Underscore and Backbone. It takes many cues from Ruby, Python, and Haskell, and focuses on the “good parts” of JavaScript made popular by Douglas Crockford in his book JavaScript: The Good Parts (O’Reilly Media, 2008). CoffeeScript achieved this by hiding many of what users refer to as the warts of JavaScript and only exposing the safer parts.