The resulting language looks much like indent based Ruby.
npm install -g coffee-script
It is possible to run CoffeeScript on the browser, but it is not recommended to do so unless the goal is to allow users to input CoffeeScript because:
- the compiler itself is quite large, 39Kb vs jQuery's 29Kb
- everything is evaluated inside a single
evalstatement, making it harder to debug
See <browser.html> for a working example.
Ups and downs
- write less
- avoid newbie mistakes mistakes
- learn yet another language
- one extra compile step. But now you can run programs simply with
- if an exception is raised at line X, you need a tool to discover what CoffeScript line it is. The above solution is not yet perfect: http://stackoverflow.com/questions/15291424/coffeescript-source-maps-for-nodejs-development
.js and runs with
node. Does not generate a
coffee -c a.coffee
Compile from stdin to stdout:
echo '@a = 0' | coffee -cs
watch: compile automatically on file save for any files under current directory:
coffee -cw .
Also set output directory:
coffee -cw -o "./dist/" .
Only watch a single file:
coffee -cw a.coffee
CSON: CoffeScript for JSON: https://github.com/bevry/cson