Friday, July 29, 2011

Get Start with CoffeeScript

What is CoffeeScript?
For starter, it is a language that compiles to JavaScript prior to execution, so there’s no compilation at runtime. And let's quote from their website:-
The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly (and vice-versa). The compiled output is readable and pretty-printed, passes through JavaScript Lint without warnings, will work in every JavaScript implementation, and tends to run as fast or faster than the equivalent handwritten JavaScript.

For example

square = (x) -> x * x
cube   = (x) -> square(x) * x
will translate to 

var cube, square;
square = function(x) {
  return x * x;
cube = function(x) {
  return square(x) * x;

There are some useful links you can take a look in order to understand or get familiar with it, if you will.

No comments:

Post a Comment