What is CoffeeScript?

A language that compiles to JavaScript. This repo is written in CoffeeScript, about CoffeeScript.

View Repository on GitHub

What is CoffeeScript?

Language: CoffeeScript 2.7.0

Compiles to: JavaScript (ES6)

Created: Jeremy Ashkenas, 2009


What it is

CoffeeScript is a small language that compiles to JavaScript. You write .coffee files, run the compiler, and get plain .js files back.

Jeremy Ashkenas built it in 2009 because JavaScript at the time was painful to write. No arrow functions, no string interpolation, no destructuring, no classes. CoffeeScript gave you all of that years before ES6 existed. A lot of what you write in modern JavaScript today traces directly back to ideas CoffeeScript popularised first.

Note: This repo is written in CoffeeScript, about CoffeeScript. The compiled .js files are included so you can run everything without installing CoffeeScript first.

Quick syntax reference

FeatureJavaScriptCoffeeScript

Files in this repo

Files

Running it


Should you use it for a new project?

Probably not. ES6+ covers most of what CoffeeScript offered, and TypeScript is the better pick if you want a compile-to-JS language with real tooling support.

That said, it is worth knowing:

  • A lot of older codebases still use it, especially Rails apps
  • ES6 syntax owes a lot to CoffeeScript
  • It compiles to readable JavaScript, so picking it up is low risk
  • The source for this repo is CoffeeScript, so you can see exactly how it works

References

Ashkenas, J. CoffeeScript: Accelerated JavaScript Development. Pragmatic Bookshelf, 2011.

CoffeeScript Language Reference: coffeescript.org

ECMA International. ECMAScript 2015 Language Specification. ECMA-262, 6th Edition, 2015.

examples.coffeeCoffeeScript
Loading...
compare.coffeeCoffeeScript
Loading...
classes.coffeeCoffeeScript
Loading...
README.mdMarkdown