I'm fairly excited about this direction for the language, and am looking
forward to writing (and more importantly, reading) more programs in this style.
More information about Literate CoffeeScript, including an
example program,
are available in this blog post.

mobyDick = "Call me Ishmael. Some years ago --
never mind how long precisely -- having little
or no money in my purse, and nothing particular
to interest me on shore, I thought I would sail
about a little and see the watery part of the
world..."

var mobyDick;
mobyDick = "Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world...";

Cake, and Cakefiles

CoffeeScript includes a (very) simple build system similar to
Make and
Rake. Naturally,
it's called Cake, and is used for the tasks that build and test the CoffeeScript
language itself. Tasks are defined in a file named Cakefile, and
can be invoked by running cake [task] from within the directory.
To print a list of all the tasks and options, just type cake.

Task definitions are written in CoffeeScript, so you can put arbitrary code
in your Cakefile. Define a task with a name, a long description, and the
function to invoke when the task is run. If your task takes a command-line
option, you can define the option with short and long flags, and it will
be made available in the options object. Here's a task that uses
the Node.js API to rebuild CoffeeScript's parser:

If you need to invoke one task before another — for example, running
build before test, you can use the invoke function:
invoke 'build'. Cake tasks are a minimal way to expose your
CoffeeScript functions to the command line, so
don't expect any fanciness built-in.
If you need dependencies, or async callbacks, it's best to put them in your
code itself — not the cake task.

Source Maps

CoffeeScript 1.6.1 and above include support for generating source maps,
a way to tell your JavaScript engine what part of your CoffeeScript
program matches up with the code being evaluated. Browsers that support it
can automatically use source maps to show your original source code
in the debugger. To generate source maps alongside your JavaScript files,
pass the --map or -m flag to the compiler.

For a full introduction to source maps, how they work, and how to hook
them up in your browser, read the
HTML5 Tutorial.

"text/coffeescript" Script Tags

While it's not recommended for serious use, CoffeeScripts may be included
directly within the browser using <script type="text/coffeescript">
tags. The source includes a compressed and minified version of the compiler
(Download current version here, 39k when gzipped)
as extras/coffee-script.js. Include this file on a page with
inline CoffeeScript tags, and it will compile and evaluate them in order.

In fact, the little bit of glue script that runs "Try CoffeeScript" above,
as well as the jQuery for the menu, is implemented in just this way.
View source and look at the bottom of the page to see the example.
Including the script also gives you access to CoffeeScript.compile()
so you can pop open Firebug and try compiling some strings.

The usual caveats about CoffeeScript apply — your inline scripts will
run within a closure wrapper, so if you want to expose global variables or
functions, attach them to the window object.

Books

There are a number of excellent resources to help you get
started with CoffeeScript, some of which are freely available online.

CoffeeScript Ristretto
is a deep dive into CoffeeScript's semantics from simple functions up through
closures, higher-order functions, objects, classes, combinators, and decorators.
By Reg Braithwaite.

Testing with CoffeeScript
is a succinct and freely downloadable guide to building testable
applications with CoffeeScript and Jasmine.

CoffeeScript Application Development
is a new book from Packt Publishing that introduces CoffeeScript while
walking through the process of building a demonstration web application.

CoffeeScript in Action
is a new book from Manning Publications that covers CoffeeScript syntax, composition techniques
and application development.

Resources

Source Code
Use bin/coffee to test your changes,bin/cake test to run the test suite,bin/cake build to rebuild the CoffeeScript compiler, and bin/cake build:parser to regenerate the Jison parser if you're
working on the grammar.

git checkout lib && bin/cake build:full is a good command to run when you're working
on the core language. It'll refresh the lib directory
(in case you broke something), build your altered compiler, use that to
rebuild itself (a good sanity test) and then run all of the tests. If
they pass, there's a good chance you've made a successful change.

JS2Coffee
Is a very well done reverse JavaScript-to-CoffeeScript compiler. It's
not going to be perfect (infer what your JavaScript classes are, when
you need bound functions, and so on...) — but it's a great starting
point for converting simple scripts.

High-Rez Logo
The CoffeeScript logo is available in Illustrator, EPS and PSD formats, for use
in presentations.

Web Chat (IRC)

Quick help and advice can usually be found in the CoffeeScript IRC room.
Join #coffeescript on irc.freenode.net, or click the
button below to open a webchat session on this page.

Change Log

When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with require 'coffee-script/register' or CoffeeScript.register(). Also for configuration such as Mocha's, use coffee-script/register.

Multiline strings are now joined by a single space and ignore all indentation. A backslash at the end of a line can denote the amount of whitespace between lines, in both strings and heredocs. Backslashes correctly escape whitespace in block regexes.

Closing brackets can now be indented and therefore no longer cause unexpected error.

Source maps have been used to provide automatic line-mapping when
running CoffeeScript directly via the coffee command, and
for automatic line-mapping when running CoffeeScript directly in the
browser. Also, to provide better error messages for semantic errors
thrown by the compiler —
with colors, even.

Improved support for mixed literate/vanilla-style CoffeeScript projects,
and generating source maps for both at the same time.

First release of source maps. Pass the
--map flag to the compiler, and off you go. Direct all your
thanks over to Jason Walton.

Fixed a 1.5.0 regression with multiple implicit calls against an
indented implicit object. Combinations of implicit function calls
and implicit objects should generally be parsed better now —
but it still isn't good style to nest them too heavily.

.coffee.md is now also supported as a Literate CoffeeScript
file extension, for existing tooling.
.litcoffee remains the canonical one.

Several minor fixes surrounding member properties, bound methods and
super in class declarations.

CoffeeScript now enforces all of JavaScript's Strict Mode early syntax
errors at compile time. This includes old-style octal literals,
duplicate property names in object literals, duplicate parameters in
a function definition, deleting naked variables, setting the value of
eval or arguments, and more.
See a full discussion at
#1547.

The REPL now has a handy new multi-line mode for entering large
blocks of code. It's useful when copy-and-pasting examples into the
REPL. Enter multi-line mode with Ctrl-V. You may also now
pipe input directly into the REPL.

CoffeeScript now prints a Generated by CoffeeScript VERSION
header at the top of each compiled file.

Conditional assignment of previously undefined variables
a or= b is now considered a syntax error.

A tweak to the semantics of do, which can now be used to
more easily simulate a namespace: do (x = 1, y = 2) -> ...

Loop indices are now mutable within a loop iteration, and immutable
between them.

Both endpoints of a slice are now allowed to be omitted for consistency,
effectively creating a shallow copy of the list.

Additional tweaks and improvments to coffee --watch under
Node's "new" file watching API. Watch will now beep by default
if you introduce a syntax error into a watched script. We also now
ignore hidden directories by default when watching recursively.

Multiple improvements to coffee --watch and --join.
You may now use both together, as well as add and remove
files and directories within a --watch'd folder.

The throw statement can now be used as part of an expression.

Block comments at the top of the file will now appear outside of the
safety closure wrapper.

Fixed a number of minor 1.1.3 regressions having to do with trailing
operators and unfinished lines, and a more major 1.1.3 regression that
caused bound functions within bound class functions to have the incorrect
this.

Ahh, whitespace. CoffeeScript's compiled JS now tries to space things
out and keep it readable, as you can see in the examples on this page.

You can now call super in class level methods in class bodies,
and bound class methods now preserve their correct context.

JavaScript has always supported octal numbers 010 is 8,
and hexadecimal numbers 0xf is 15, but CoffeeScript now
also supports binary numbers: 0b10 is 2.

The CoffeeScript module has been nested under a subdirectory to make
it easier to require individual components separately, without
having to use npm. For example, after adding the CoffeeScript
folder to your path: require('coffee-script/lexer')

There's a new "link" feature in Try CoffeeScript on this webpage. Use
it to get a shareable permalink for your example script.

The coffee --watch feature now only works on Node.js 0.6.0
and higher, but now also works properly on Windows.

1.1.0
– May 1, 2011
When running via the coffee executable, process.argv and
friends now report coffee instead of node.
Better compatibility with Node.js 0.4.x module lookup changes.
The output in the REPL is now colorized, like Node's is.
Giving your concatenated CoffeeScripts a name when using --join is now mandatory.
Fix for lexing compound division /= as a regex accidentally.
All text/coffeescript tags should now execute in the order they're included.
Fixed an issue with extended subclasses using external constructor functions.
Fixed an edge-case infinite loop in addImplicitParentheses.
Fixed exponential slowdown with long chains of function calls.
Globals no longer leak into the CoffeeScript REPL.
Splatted parameters are declared local to the function.

1.0.0
– Dec 24, 2010
CoffeeScript loops no longer try to preserve block scope when functions
are being generated within the loop body. Instead, you can use the
do keyword to create a convenient closure wrapper.
Added a --nodejs flag for passing through options directly
to the node executable.
Better behavior around the use of pure statements within expressions.
Fixed inclusive slicing through -1, for all browsers, and splicing
with arbitrary expressions as endpoints.

0.9.6
– Dec 6, 2010
The REPL now properly formats stacktraces, and stays alive through
asynchronous exceptions. Using --watch now prints timestamps as
files are compiled. Fixed some accidentally-leaking variables within
plucked closure-loops. Constructors now maintain their declaration
location within a class body. Dynamic object keys were removed.
Nested classes are now supported. Fixes execution context for naked
splatted functions. Bugfix for inversion of chained comparisons.
Chained class instantiation now works properly with splats.

0.9.5
– Nov 21, 2010
0.9.5 should be considered the first release candidate for CoffeeScript 1.0.
There have been a large number of internal changes since the previous release,
many contributed from satyr's Coco
dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions
can now have default arguments. Class bodies are now executable code.
Improved syntax errors for invalid CoffeeScript. undefined now
works like null, and cannot be assigned a new value.
There was a precedence change with respect to single-line comprehensions:
result = i for i in list used to parse as result = (i for i in list)
by default ... it now parses as (result = i) for i in list.

0.9.4
– Sep 21, 2010
CoffeeScript now uses appropriately-named temporary variables, and recycles
their references after use. Added require.extensions support for
Node.js 0.3. Loading CoffeeScript in the browser now adds just a
single CoffeeScript object to global scope.
Fixes for implicit object and block comment edge cases.

0.9.3
– Sep 16, 2010
CoffeeScript switch statements now compile into JS switch
statements — they previously compiled into if/else chains
for JavaScript 1.3 compatibility.
Soaking a function invocation is now supported. Users of the RubyMine
editor should now be able to use --watch mode.

0.9.2
– Aug 23, 2010
Specifying the start and end of a range literal is now optional, eg. array[3..].
You can now say a not instanceof b.
Fixed important bugs with nested significant and non-significant indentation (Issue #637).
Added a --require flag that allows you to hook into the coffee command.
Added a custom jsl.conf file for our preferred JavaScriptLint setup.
Sped up Jison grammar compilation time by flattening rules for operations.
Block comments can now be used with JavaScript-minifier-friendly syntax.
Added JavaScript's compound assignment bitwise operators. Bugfixes to
implicit object literals with leading number and string keys, as the subject
of implicit calls, and as part of compound assignment.

0.9.0
– Aug 4, 2010
The CoffeeScript 0.9 series is considered to be a release candidate
for 1.0; let's give her a shakedown cruise. 0.9.0 introduces a massive
backwards-incompatible change: Assignment now uses =, and object
literals use :, as in JavaScript. This allows us to have implicit
object literals, and YAML-style object definitions. Half assignments are
removed, in favor of +=, or=, and friends.
Interpolation now uses a hash mark # instead of the dollar sign
$ — because dollar signs may be part of a valid JS identifier.
Downwards range comprehensions are now safe again, and are optimized to
straight for loops when created with integer endpoints.
A fast, unguarded form of object comprehension was added:
for all key, value of object. Mentioning the super keyword
with no arguments now forwards all arguments passed to the function,
as in Ruby. If you extend class B from parent class A, if
A has an extended method defined, it will be called, passing in B —
this enables static inheritance, among other things. Cleaner output for
functions bound with the fat arrow. @variables can now be used
in parameter lists, with the parameter being automatically set as a property
on the object — useful in constructors and setter functions.
Constructor functions can now take splats.

0.7.2
– Jul 12, 2010
Quick bugfix (right after 0.7.1) for a problem that prevented coffee
command-line options from being parsed in some circumstances.

0.7.1
– Jul 11, 2010
Block-style comments are now passed through and printed as JavaScript block
comments -- making them useful for licenses and copyright headers. Better
support for running coffee scripts standalone via hashbangs.
Improved syntax errors for tokens that are not in the grammar.

0.7.0
– Jun 28, 2010
Official CoffeeScript variable style is now camelCase, as in JavaScript.
Reserved words are now allowed as object keys, and will be quoted for you.
Range comprehensions now generate cleaner code, but you have to specify by -1
if you'd like to iterate downward. Reporting of syntax errors is greatly
improved from the previous release. Running coffee with no arguments
now launches the REPL, with Readline support. The <- bind operator
has been removed from CoffeeScript. The loop keyword was added,
which is equivalent to a while true loop. Comprehensions that contain
closures will now close over their variables, like the semantics of a forEach.
You can now use bound function in class definitions (bound to the instance).
For consistency, a in b is now an array presence check, and a of b
is an object-key check. Comments are no longer passed through to the generated
JavaScript.

0.6.2
– May 15, 2010
The coffee command will now preserve directory structure when
compiling a directory full of scripts. Fixed two omissions that were preventing
the CoffeeScript compiler from running live within Internet Explorer.
There's now a syntax for block comments, similar in spirit to CoffeeScript's heredocs.
ECMA Harmony DRY-style pattern matching is now supported, where the name
of the property is the same as the name of the value: {name, length}: func.
Pattern matching is now allowed within comprehension variables. unless
is now allowed in block form. until loops were added, as the inverse
of while loops. switch statements are now allowed without
switch object clauses. Compatible
with Node.js v0.1.95.

0.5.6
– Mar 23, 2010
Interpolation can now be used within regular expressions and heredocs, as well as
strings. Added the <- bind operator.
Allowing assignment to half-expressions instead of special ||=-style
operators. The arguments object is no longer automatically converted into
an array. After requiring coffee-script, Node.js can now directly
load .coffee files, thanks to registerExtension. Multiple
splats can now be used in function calls, arrays, and pattern matching.

0.5.5
– Mar 8, 2010
String interpolation, contributed by
Stan Angeloff.
Since --run has been the default since 0.5.3, updating
--stdio and --eval to run by default, pass --compile
as well if you'd like to print the result.

0.5.3
– Feb 27, 2010
CoffeeScript now has a syntax for defining classes. Many of the core
components (Nodes, Lexer, Rewriter, Scope, Optparse) are using them.
Cakefiles can use optparse.coffee to define options for tasks.
--run is now the default flag for the coffee command,
use --compile to save JavaScripts. Bugfix for an ambiguity between
RegExp literals and chained divisions.

0.5.2
– Feb 25, 2010
Added a compressed version of the compiler for inclusion in web pages as
extras/coffee-script.js. It'll automatically run any script tags
with type text/coffeescript for you. Added a --stdio option
to the coffee command, for piped-in compiles.

0.5.1
– Feb 24, 2010
Improvements to null soaking with the existential operator, including
soaks on indexed properties. Added conditions to while loops,
so you can use them as filters with when, in the same manner as
comprehensions.

0.5.0
– Feb 21, 2010
CoffeeScript 0.5.0 is a major release, While there are no language changes,
the Ruby compiler has been removed in favor of a self-hosting
compiler written in pure CoffeeScript.

0.3.2
– Feb 8, 2010@property is now a shorthand for this.property.
Switched the default JavaScript engine from Narwhal to Node.js. Pass
the --narwhal flag if you'd like to continue using it.

0.3.0
– Jan 26, 2010
CoffeeScript 0.3 includes major syntax changes:
The function symbol was changed to
->, and the bound function symbol is now =>.
Parameter lists in function definitions must now be wrapped in parentheses.
Added property soaking, with the ?. operator.
Made parentheses optional, when invoking functions with arguments.
Removed the obsolete block literal syntax.

0.2.5
– Jan 13, 2010
The conditions in switch statements can now take multiple values at once —
If any of them are true, the case will run. Added the long arrow ==>,
which defines and immediately binds a function to this. While loops can
now be used as expressions, in the same way that comprehensions can. Splats
can be used within pattern matches to soak up the rest of an array.

0.2.3
– Jan 11, 2010
Axed the unsatisfactory ino keyword, replacing it with of for
object comprehensions. They now look like: for prop, value of object.

0.2.2
– Jan 10, 2010
When performing a comprehension over an object, use ino, instead
of in, which helps us generate smaller, more efficient code at
compile time.
Added :: as a shorthand for saying .prototype.
The "splat" symbol has been changed from a prefix asterisk *, to
a postfix ellipsis ...
Added JavaScript's in operator,
empty return statements, and empty while loops.
Constructor functions that start with capital letters now include a
safety check to make sure that the new instance of the object is returned.
The extends keyword now functions identically to goog.inherits
in Google's Closure Library.

0.1.5
– Dec 26, 2009
Array slice literals and array comprehensions can now both take Ruby-style
ranges to specify the start and end. JavaScript variable declaration is
now pushed up to the top of the scope, making all assignment statements into
expressions. You can use \ to escape newlines.
The coffee-script command is now called coffee.

0.1.4
– Dec 25, 2009
The official CoffeeScript extension is now .coffee instead of
.cs, which properly belongs to
C#.
Due to popular demand, you can now also use = to assign. Unlike
JavaScript, = can also be used within object literals, interchangeably
with :. Made a grammatical fix for chained function calls
like func(1)(2)(3)(4). Inheritance and super no longer use
__proto__, so they should be IE-compatible now.

0.1.3
– Dec 25, 2009
The coffee command now includes --interactive,
which launches an interactive CoffeeScript session, and --run,
which directly compiles and executes a script. Both options depend on a
working installation of Narwhal.
The aint keyword has been replaced by isnt, which goes
together a little smoother with is.
Quoted strings are now allowed as identifiers within object literals: eg.
{"5+5": 10}.
All assignment operators now use a colon: +:, -:,
*:, etc.

0.1.2
– Dec 24, 2009
Fixed a bug with calling super() through more than one level of
inheritance, with the re-addition of the extends keyword.
Added experimental Narwhal
support (as a Tusk package), contributed by
Tom Robinson, including
bin/cs as a CoffeeScript REPL and interpreter.
New --no-wrap option to suppress the safety function
wrapper.