I like programming languages with rich object models. I love dynamic languages. Sure, minimizing execution time and resource optimization may demand speed, and c variants and java (mirah!) are screamers. Yet after having coded heavily in one of these languages for years, it's a breath of fresh air letting go of the training wheels of type safety and discarding the mental overhead of complex inheritance trees. Verbosity be damned!
An object is the interface it defines.
CoffeeScriptsquare = (x) -> x * x math = root: Math.sqrt square: square cube: (x) -> x * square x list = [1, 2, 3, 4, 5] cubes = (math.cube num for num in list)
I found nvm a great configuration tool for keeping my versions of node straightI opted to manually install and maintain node versions for the time being. I had issues with where nvm was installing files and some conflicts with npm.
The following installation instructions are from Jashkenas github linked above:
Installation and Usage
To install, first make sure you have a working copy of the latest stable version of Node.js, and npm (the Node Package Manager). You can then install CoffeeScript with npm:
npm install -g coffee-script
(Leave off the -g if you don’t wish to install globally.)
If you’d prefer to install the latest master version of CoffeeScript, you can clone the CoffeeScript source repository from GitHub, or download the source directly. To install the CoffeeScript compiler system-wide under /usr/local, open the directory and run:
sudo bin/cake install
If installing on Ubuntu or Debian, be careful not to use the existing out-of-date package. If installing on Windows, your best bet is probably to run Node.js under Cygwin.
Once installed, you should have access to the coffee command, which can execute scripts, compile .coffee files into .js, and provide an interactive REPL.
- For a great example of CoffeeScript in action, check out Zombie.js. There are already far too many wonderful coffeescript examples for me to cite, it's an extraordinarily fast growing language translation.
- News at YCombinator conversation about CoffeeScript's latest release