Description straight from coffeescript.org,
For the sake of this guide I am going to assume you are running a Debian or Ubuntu based operation system. If you're running anything else, you probably know what you're doing anyways.
$ sudo apt-get install nodejs nodejs-dev npm $ sudo npm install -g coffee-script
Yay! Now we have the CoffeeScript compiler installed! Let's create some simple code and run it.
HelloWorld.coffee' and save it.
# Yet Another CoffeeScript HelloWorld # By the way, '#' is a comment in CoffeeScript # Also, 'console.log' prints text ## Define some functions ## square = (x) -> x * x cube = (x) -> square(x) * x printSquare = (x) -> mySquare = square(x) console.log "The square of", x, "is", mySquare ## Loop example ## for num in [1..5] printSquare(num) console.log "" # sends a newline cubeMe = [ 123, 124, 125, 122, 121, 120 ] cubes = (cube x for x in cubeMe) # Print first 5 cubes for c in [0..4] console.log cubeMe[c] + "^3 ->", cubes[c] console.log "" console.log "Oh yeah, I forgot..." console.log "HELLO WORLD!"
Simply run the file with:
$ coffee HelloWorld.coffee
$ coffee -c HelloWorld.coffee
Yay, we did it! We compiled some CoffeeScript code and ran it! Well, that's the gist of it. To learn more about CoffeeScript, checkout the links below.
If you want to learn CoffeeScript extensively, read this little e-book called The Little Book of CoffeeScript.