CoffeeScript is a programming language that compiles to JavaScript. Created by Jeremy Ashkenas, it added syntactic sugar inspired by Ruby and Python, making JavaScript development more pleasant before ES6 modernized the language.
Origins
Ashkenas created CoffeeScript in 2009, frustrated by JavaScript’s verbose syntax. CoffeeScript offered cleaner alternatives: arrow functions, classes, destructuring, and more.
Key Features
CoffeeScript introduced conveniences:
- Arrow functions:
->and=>for functions - Classes: Clean class syntax
- Destructuring: Pattern-matching assignment
- String interpolation: Variables in strings
- List comprehensions: Declarative iteration
- Significant whitespace: Python-style indentation
Peak Adoption
CoffeeScript was hugely popular from 2010-2015:
- Dropbox used it extensively
- Rails included CoffeeScript support
- Many developers preferred it to JavaScript
Legacy
Ironically, CoffeeScript’s success led to its decline. ES6 (2015) adopted many CoffeeScript features—arrow functions, classes, destructuring, template literals—making CoffeeScript less necessary. The language proved these features were wanted; JavaScript just needed to add them.