CoffeeScript (CS) Intro, Examples and Tutorials
It is an open source language, and ongoing development is completed in collaboration between Ashkenas and an army of nearly 200 contributors.
History of CoffeeScript
In December of 2009, Jeremy Ashkenas created a new GitHub repository with an initial commit tagged as "initial commit of the mystery language."
This initial commit was rapidly built upon and the first official release of the language, CS version 0.1.0, came less than 2 weeks later on Christmas Eve of 2009.
The CS compiler was originally written in Ruby. However, version 0.5, released in February of 2010, replaced the compiler with one written in CoffeeScript itself. However, there was still a ways to go before the first stable version of CS, version 1.0.0, which was released on Christmas Eve of 2010, approximately one year after the project sprang to life.
CoffeeScript is in version 1.11.0 as 2016 draws to a close, with the latest version having been released in early October 2016. Development of the next generation of CS, CoffeeScript 2.0, is well underway and will be marked by two primary feature additions:
Addition of classes output with the class keyword to CS compiler.
The planned updates to version 2.0 are breaking changes — in other words, code written for CS 2.0 will not be properly compiled by any 1.X compiler.
Thus the need for a new major version update to the language. To keep abreast of the latest development work being done on CS, refer to the CoffeeScript 6.0 GitHub repository.
Jeremy is also a developer for The New York Times as well as a popular speaker for conferences and you will find many videos of his talks on YouTube, such as:
Most notably, curly braces, semicolons, and the use of assignment keywords like
function are all omitted in CS.
As you can see, the CS version is cleaner, shorter, and contains fewer language operators. This makes the CS version a bit faster to type, but it also masks what is going on behind the scenes to a certain degree.
One interesting variation of CS is called literate CoffeeScript. The compiler will recognize this variation as long as the source code file ends with the extension .litcoffee rather than .coffee.
Literate CS allows developers to write code using markdown syntax. All writing will be ignored by the compiler as commentary while indented code blocks are recognized as program code.
Let's look at a short example.
How to Get CoffeeScript
If you aren't ready to install CoffeeScript quite yet, you can also give it a spin by heading to CoffeeScript.org and selecting the Try CoffeeScript tab.
A Sip of CoffeeScript: a short and free introductory course from CodeSchool.
The Absolute Beginner's Guide to CoffeeScript: this tutorial lives up to its name, getting the software installed and teaching the basics of the language.
CoffeeScript.org: the official CS website includes a detailed introduction to the language and a browser-based compiler.
Smooth CoffeeScript: an interactive, free, browser-based ebook.
CoffeeScript: Your Guide Book on App Development with CoffeScript (2016) by Nicholas Brown.
CoffeeScript in Action (2014) by Lee and Marino.
CoffeeScript is a programming language with a concise syntax that minimizes the use of the keywords and operators and enables developers to write elegant code quickly.
Further Reading and Resources
We have more guides, tutorials, and infographics related to coding and development:
What Code Should You Learn?
Confused about what programming language you should learn to code in? Check out our infographic, What Code Should You Learn?