Just recently I heard fellows on Twitter talking about CoffeeScript. I believe I heard the name before but I was very busy couldn’t even have a look. This time I tried to check what is that.
It turns out to be a new way for writing JavaScript that is more compact & dynamic, and resembles Ruby and Python dynamic languages. After I gave it few hours & I felt I like it.
The idea behind this new language is to write your code in a dynamic syntax that later can be compiled to generate a 100% equivalent JavaScript that's granted to be always valid if you check it against a tool like JavaScript Lint. The gain of this is brevity and readability, typically 1/3 fewer lines with no effect on runtime performance.
First issue I faced was how to get it working on my PC? The installation on Windows is somehow long & complex; no single-filre installer available for Windows on the official site yet. But I found this project that simplifies compiling CoffeeScript into JavaScript on Windows. Hence, my first environment consisted of a good text editor, Notepad++, and a CoffeeScript Compiler for Windows. There's another simple alternative, the online compiler available on official site called "TRY COFFEESCRIPT".
What I liked about this language that I can write complex JavaScript in a more compact & readable form. The major difference for me, since that I’m not a good JavaScript developer, I don’t like the way JavaScript define classes. JavaScript way of defining classes sounds, for me, a method-oriented way than an object-oriented way. But when tried CoffeeScript I was able to express my thoughts in an object-oriented way. Moreover, It has a dynamic syntax similar to Ruby & Python that takes indentation into account instead of braces and parentheses to make your code looks more readable & expressive; though I love static languages in general & specifically C# :)
Using my simple environment, I managed to write my first simple program. I found Ayende’s latest challenge for Tax Calculation a good start, so I decided to write my answer in CoffeeScript. You can find this simple program in this GitHub:Gist. The screenshot below can give u an idea about how does it look like if u didn’t check the official site yet.
This is my first account about CoffeeScript, the second will come soon about preparing a better environment for developing on Windows, probably also on Ubuntu.
Enjoy learning... :)