CoffeeScript

CoffeeScript

CoffeeScript is a little language that compiles into JavaScript. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.

CoffeeScript was one of the pioneers of the compile-to-JavaScript concept. In fact, some of things you now see in the modern JavaScript appeared in the first version of CoffeeScript some 8 years ago. And 2 years short of a decade later, JavaScript assimilated some of the CoffeeScript features, and at least some folks out there got the idea that CoffeeScript is finished.

CoffeeScript started as an attempt to make JavaScript more readable. It does so by making many things optional, and, at the same time, enforcing other things. For example, arrow functions are used instead of the classic function declarations, not in addition to them. Blocks are all without braces and parenthesis, and whitespace is used to denote blocks, like in Python. You can say things like for i in someArray. You can use [n..m] for to define arrays based on numeric ranges. 

And that’s what makes CoffeeScript even more attractive. If you know JavaScript (and you probably would not be reading this if you did not), CoffeeScript doesn’t force you to learn new language semantics. In other words, you can do things the way you’re used to most of the time.

Since the second version, CoffeeScript compiles directly to the modern JavaScript instead of ES3, which means we can use modern features like async/await, generators, JSX, classes, and the new module syntax (import, export).

CoffeeScript is rumored to be made by people who dislike JavaScript syntax for people who equally dislike JavaScript syntax. It might even go so far as to help people who don’t understand how JavaScript works at its roots to write more optimized code, since the compilation into JavaScript is implemented pretty well from a performance point of view.