Imagine if you will, you have to write an article in Latin. You don’t speak Latin and rather than take the time to learn it, you learn Spanish and use a tool to translate it all into Latin for you. It wouldn’t necessarily be the most readable article and you certainly wouldn’t understand the output, after all you don’t speak Latin, but it should be grammatically accurate.
So, how can a developer leverage the newer ECMAScript features and/or TypeScript (or keeping with the analogy, Spanish and Esperanto respectively) and still create a solution with support across multiple browsers and platforms? Transpiling, that’s how. Yep, that’s right, it’s not a typo, TRANSPILING is the actual term. A cross between translating and compiling, it takes your potentially uninterpretable code and converts it into a more widely recognised syntax, effectively ECMAScript 5 (Latin).
One way to transpile, would be to use a build tool such as Grunt, Gulp or Webpack, typically in combination with Babel (the transpiler). These tools allow developers to break their projects down into manageable modules and then bring them all together into a distributable solution. With a build tool, code can be compressed, uglified, transpiled and do many other ‘made up verb’ type tasks.
With so many resources online and many of the newer ones based on this way of working, newer developers can be mislead into thinking that this is how they should do things, or, they can feel intimidated by or get lost in the number of moving parts required to write code.
In my own projects I avoid TypeScript at all costs but, I do, however, use build tools, keep up to date with the latest syntax and occasionally transpile.
Noobs of the world, don’t get lost in transpilation. Take the time to learn the fundamentals.
What are your thoughts? Leave any questions or feedback in the comments. Thanks!