Welcome to the coding world of CoffeeScript - FAMINE NEWS

Breaking

BANNER

Monday, December 3, 2012

Welcome to the coding world of CoffeeScript

JavaScript not withstanding can be turned off on browsers, yet it as become an important part of a website as it allow the developer to interact directly with the web browser. Since 2005, lots of new JavaScript techniques and tools such as Ajax and jQuery became extremely popular and made the web a better place especially for locations where flash players are not accessible they attempt to replace with  scrolling or faders. Today, I’m introducing to you CoffeeScript, a new language that makes JavaScript better and simpler.

What is CoffeeScript?

To keep it simple, CoffeeScript is a little language that compiles into JavaScript. If you ever coded in languages such as Python or Ruby, you’ll probably love CoffeeScript a lot. Instead of awkward braces and semicolons, JavaScript has always had a gorgeous object model at its heart. It aims to smooth over some of JavaScript’s rougher edges while highlighting and augmenting the impressive flexibility at the core of the JavaScript language.
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 from CoffeeScript (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.

Installing CoffeeScript

Installing CoffeeScript is not hard at all. The first thing to do is to make sure that you already installed a working copy of the latest stable version of Node.js as well as npm, the Node Package Manager.
Once done, you can install CoffeeScript by running the following command:
npm install -g coffee-script
CoffeeScript is now installed. Next step is to compile a .coffee file into a .js file. Use the following syntax to do so:
coffee --compile example.coffee
CoffeeScript.org is the official website of the CoffeeScript language. Don’t hesitate to visit it, it’s full of helpful ressources.

The CoffeeScript compiler is itself written in CoffeeScript, using the Jison parser generator. The command-line version of coffee is available as a Node.js utility. The core compiler however, does not depend on Node, and can be run in any JavaScript environment, or in the browser (see "Try CoffeeScript", above).

To install, first make sure you have a working copy of the latest stable version of Node.js, and npm (the Node Package Manager). You can then install CoffeeScript with npm:

npm install -g coffee-script

(Leave off the -g if you don't wish to install globally.)
If you'd prefer to install the latest master version of CoffeeScript, you can clone the CoffeeScript source repository from GitHub, or download the source directly. To install the lastest master CoffeeScript compiler with npm:
 
npm install -g http://github.com/jashkenas/coffee-script/tarball/master

Or, if you want to install to /usr/local, and don't want to use npm to manage it, open the coffee-script directory and run:
 
sudo bin/cake install