CoffeeScript Compiler

What is this?

An online instance of the CoffeeScript compiler.

What is CoffeeScript?

CoffeeScript is the most popular of large list of languages that compiles to JavaScript. Its semantics are very similar to JavaScript and it maps very directly to JavaScript. The output of the compiler is generally human readable.

Its syntax eliminates boilerplate you’d find in plain Javascript. For example it adds a new notation for defining functions using the -> operator, letting you write

square = (x) -> x * x

rather than

square = function(x) { return x * x }

This is particularly convenient for working with higher-order functions like map, filter, and reduce, where the verbose Javascript syntax for anonymous functions can hinder readability.

It adds many other features such as special loops for iterating over keys and values of objects, syntax for creating traditional OO classes, array comprehension, and more. It uses significant whitespace, like Python, to delimit blocks of code, rather than curly braces.

Many people find it cleaner and less noisy than Javascript, but argue the syntax changes don’t offer enough value to be worth the complexities of introducing a new language, adding steps to your build process, and overhead to debugging. Check out CoffeeScript’s website to learn more and decide for yourself.