Introducción

CoffeeScript is a programming language that looks like this:

[~/coffee/jump_start_coffeescript/chapter01/casiano(master)]$ coffee
coffee> hello = (name) -> "Hello, #{name}!"
[Function]
coffee> hello('world!')
'Hello, world!!'
coffee> hello 'world!'
'Hello, world!!'

Here, we’re defining and then calling a function, hello, which accepts a single parameter, name.

Instalación

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 browse.

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

CoffeeScript includes a (very) simple build system similar to Make and Rake. Naturally, it's called Cake , and is used for the tasks that build and test the CoffeeScript language itself. Tasks are defined in a file named Cakefile, and can be invoked by running cake [task] from within the directory. To print a list of all the tasks and options, just type cake.

Enlaces Relacionados

  1. CoffeeScript book
  2. Railcast: CoffeeScript
  3. vim plugin para CoffeScript
  4. A CoffeeScript Intervention. Five Things You Thought You Had to Live with in JavaScript por Trevor Burnham en PragPub
  5. A taste of CoffeeScript (part 2)
  6. Some real world examples of Coffescript and jQuery por Stefan Bleibinhaus



Subsecciones
Casiano Rodriguez León 2015-06-18