The benefit of transpiling es2015

Daniel Schmidt
2 min readApr 14, 2016

--

I lately read an article about the cost of transpiling by Sam Saccone and noticed some developers going wild and concluding that one should switch back to good old es5 without any of these build tools. While I found the article a great read and of high quality, I can not support the conclusion entirely. Because of that, I would like to show some quick examples how es2015 increases the readability and verbosity of your source code. In my mind, this outweighs in most cases the concerns raised.

Deconstructing

Named function arguments

Deconstruction is even better when it comes to named functions, as in this example:

What bugs me about functions with many parameters is that if they are used in multiple contexts and if they have multiple optional parameters you almost always have the case that you have to do the following:

Arrow functions

This is one of the features, which are quite often talked about, but a simple example like this could show you the real benefits:

As you see it is much clearer which function is a real one with meaning (and own execution context opposed to arrow functions) and which is just an anonymous utility function. Also, you get rid of the .bind, which is always a big plus.

Conclusion

To me, these shortcuts are the most rewarding ones, as they clear up your code and ensure a great readability. It is clear, that if your code runs under extreme circumstances (tough loading times or hard execution time limits) you might run into problems using the bigger transpiled code. But IMHO in most cases you want to write quickly and extend the code so es2015 is a great choice to do so. Please bear in mind, that the more complex and possibly more rewarding not so everyday topics like generators, proxies and modules aren’t even covered, so this is just the tip of the iceberg.

Want to hear more from me? Feel free to subscribe to my newsletter; I send out news roughly once a month.

--

--

Daniel Schmidt

Software Engineer at Mesosphere working on the DC/OS UI