Channels

Services

CoffeeScript 1.5.0 adds "Literate Programming" mode

The latest version of CoffeeScript, version 1.5.0, has added a new "literate" mode to the language to allow developers to create Markdown documents which are also executable. CoffeeScript is a small language which compiles into JavaScript while trying to expose the better nature of JavaScript.

The new "literate" mode, which is entirely optional, is another step into creating readable code. The compiler spots ".litcoffee" files and, when compiling them to JavaScript, discards everything that isn't indented and compiles only the indented text. In Markdown, it just so happens that indented text is the markup language's way of denoting source code. This means that a raw .litcoffee file can be compiled, or used to create formatted documents, and can even display in editors with syntax highlighting. The developers are seeking feedback on the "literate" mode and looking for ideas on how it can be improved.

Other changes in CoffeeScript 1.5 include switching CoffeeScript's REPL (Read-eval-print-loop) to be based on Node.js's REPL, banning the return of values from constructors, and a syntax to loop over arrays backwards (for item in list by -1).

CoffeeScript can be installed via Node.js's npm package manager; the command-line version of coffee, the CoffeeScript compiler is, itself a Node.js utility. The core compiler does not have a dependency on any environment and can even be run in a browser; the MIT-licensed code is available to download and can viewed in the project's GitHub repository.