Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Newbie question: How is CoffeeScript typically used? On a web server running node.js? In the browser after including CoffeeScript the way you might include jQuery? Either? Some other way?


Anywhere you might use JavaScript. For building web sites, working with canvas, doing servers with Node.js, or scripting the JVM with Rhino ... for example:

A Riak client: http://riakjs.org/

A canvas sketch: http://jashkenas.s3.amazonaws.com/misc/buddhabrot/buddhabrot...

A string scanning library: http://sstephenson.github.com/strscan-js/

An in-browser tank game: https://github.com/stephank/orona

A Node.js-powered Rack server: http://josh.github.com/nack/


Both.

Since CoffeeScript itself is written in CoffeeScript it was quite easy for the team to create a distribution of the compiler that runs in the browser.

You can find it in the extras folder of the source code repository.

Usually though, people opt to pre-compile their CoffeeScript on the server, pack, optimise and minify it before serving it to clients.

At Feisty, we write CoffeeScript that is intended to be executed on both the server and client.

To achieve this, we wrote "requisition" - https://github.com/feisty/requisition - a server-side packager and client-side loader - via require() - for CommonJS Modules written in CoffeeScript.

For a simpler, ad-hoc solution check out my tutorial project "Walk the Line" - http://github.com/pyrotechnick/walk_the_line




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: