Slurp - CoffeeScript Part 1
npm install -g coffee-script
that will even add CoffeeScriptto 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 CoffeeScriptprogram. 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 simpleCoffeeScript 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.