npm install -g coffee-script
that will even add CoffeeScriptÂ to your path. What a friendly fellow that node package manager is! If youâ€™re running this on OSX or Linux and you want to install it globally (thatâ€™s what the -g flag does) then youâ€™ll need to have sudo.
We can now get started with a simple CoffeeScriptÂ program. By convention CoffeeScript files end in .coffee but for maximum confusion you should end them with .java or .c (please donâ€™t). The lengthening of file extensions is kind of funny, donâ€™t you think?
So letâ€™s start with a really simpleÂ CoffeeScript program.
Iâ€™ve spoken before about how to arrange large code bases using namespaces and classes. CoffeeScript doesnâ€™t have a built in concept of namespace or module but it does have a concept of classes. You can simulate modules but thatâ€™s a lesson for another day, classes will do just fine for now.
Here you can see the syntax for setting up ifs and elses. Again notice the lack of braces, code blocks are denoted by indentation.
Over the next week Iâ€™ll be delving more into coffeescript in preparation for my talk.