Setup Mac for CoffeeScript development

For my pet projects I mainly use CoffeeScript these days.

I recently decided to do some of my mobile app development on my old mac book pro, so after installing Snow Leopard I had to do the following to get started.

Snow leopard comes preinstalled with Ruby, although I would suggest installing RVM, and Ruby 1.9.2 – there are plenty examples of doing that elsewhere. This is not a guide for Ruby development, so I’ll show the minimal required Ruby. Expect a future article on how I use Ruby and the Middleman gem to do mobile app development and using the same source to build and maintain multiple apps that share some core functionality.

First step is to make sure you have XCode installed. and specifically, be sure to have the version that includes iOS SDK. This would most likely mean that you have to download the whole 4.2+Gb. I tried downloading it from the Apple dev center a few times, only to have the download fail after 1.5~Gb . I then resorted to downloading a torrent. If you want to do development for an Apple mobile device, then you need this. You will need XCode regardless, various Ruby, Node.js and other tools/libraries rely somewhat on it.

Homebrew: Is a great package management tool for OSX. We’ll use it to install Node.js, but you’ll use it for loads of other stuff too, once you know about it.

1
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

Node.js : Server-side Javascript.

1
2
brew install node
curl http://npmjs.org/install.sh | sh

CoffeeScript: awesome language that releases the power by taking the pain out of Javascript.

1
npm install -g coffee-script

See if things work.

1
coffee -v

I’ve recently been introduced to the excellent Sublime Text 2 text editor. I know everyone has their own favourite text editor; mine was Textmate. ST2 just does everything so much nicer than any text editor i’ve tried before.

Here’s how to set it up for CoffeeScript editing:
Download it from here

Install it, then in the console:
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
git clone git://github.com/jashkenas/coffee-script-tmbundle CoffeeScript
ln -s “/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl” /usr/local/bin

I usually use the Railscast colour scheme textmate bundle, or the Twilight colour scheme. In both I just change the comments colour to be more striking.

You can create your own custom build system recipes to compile/translate CoffeeScript file from Sublime Text 2 directly. I don’t currently use this as I prefer to use the console. I might create a build system to use in the future once my project gets a bit more complex.

:franc