3 ms·
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 jQue
by gabrielroth 16y ago
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?
- jashkenas 16y agoAnywhere 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/ http://riakjs.org/ A canvas sketch: http://jashkenas.s3.amazonaws.com/misc/buddhabrot/buddhabrot.html http://jashkenas.s3.amazonaws.com/misc/buddhabrot/buddhabrot... A string scanning library: http://sstephenson.github.com/strscan-js/ http://sstephenson.github.com/strscan-js/ An in-browser tank game: https://github.com/stephank/orona https://github.com/stephank/orona A Node.js-powered Rack server: http://josh.github.com/nack/ http://josh.github.com/nack/
- pyrotechnique 16y agoBoth. 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 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 http://github.com/pyrotechnick/walk_the_line