Is CoffeeScript worth a look

What actually is CoffeeScript?

CoffeeScript is a programming language that is compiled in JavaScript and sees itself not as a competitor, but as a preprocessor for JavaScript.

CoffeeScript differs from Dart, for example, as it does not have its own VM or runtime environment.

The syntax is heavily inspired by languages ​​such as Ruby or Python and relies on a simpler notation.

CoffeeScript installation

To install the CoffeeScript transcompiler, an npm command is sufficient:

Then the command is available with which files written in CoffeeScript can be translated into JavaScript.

CoffeeScript syntax example

CoffeeScript has useful features such as multiline strings and simple array handling:

You will look in vain for curly brackets and single brackets around arguments of functions. The command can now be used to compile the code in JavaScript:

If you execute the command without the addition, the JavaScript is packed into an anonymous function and executed.

Compile CoffeeScript with Grunt

To automate the compilation of CoffeeScript in JavaScript, you can use Grunt and the plugin.

Here is an example Gruntfile.js file:

With, all files are continuously checked for changes and compiled into a corresponding file.

Conclusion

CoffeeScript has both friends and enemies. A frequent point of criticism is that developers are excluded who do not know Coffeescript. In addition, the quality of the code that is generated by the CoffeeScript compiler is always the focus of discussion.

Friends of Zen coding and no compulsory semicolons or many special characters could, however, quickly get used to it.