Pages

Monday, September 5, 2011

99 Bottles of Beer in CoffeeScript

99 Bottles of Beer is a really fun (for a geek) website that has a huge collection of programs written in different programming languages, that all print the lyrics to "99 Bottles of Beer." It is a great way to show off the basic elements of a language, such as conditionals, loops, variables, string printing, etc.

There are examples of language simplicity, such as this Python version. Or the complete absurdity of a language, like the Perl example the looks like ASCII art of bottles of beer, but is actually executable Perl. Then there are the crazy funny languages like lolcode and COW.

CoffeeScript is a language the compiles to JavaScript, but it is simple and elegant like Python. While I was learning about CoffeeScript I noticed there were no CoffeeScript versions of 99 Bottles of Beer. So I wrote one! It's not fancy, it's the most straight forward way I could think to do it. I submitted it to 99-bottles-of-beer.net, hopefully they will accept it.

If you are using Mac OS X you can use Homebrew to install CoffeeScript and Node.js (required for command-line CoffeeScript).