CoffeeScript: A New Language With A Pure Ruby Compiler
CoffeeScript (GitHub repo) is a new programming language with a pure Ruby compiler. Creator Jeremy Ashkenas calls it "JavaScript's less ostentatious kid brother" - mostly because it compiles into JavaScript and shares most of the same constructs, but with a different, tighter syntax.
Interesting trivia: Jeremy was inspired to create CoffeeScript based on code he saw while reading Create Your Own Programming Language by Marc Andre Cournoyer!
To get a feel for the language, check out this example code (CoffeeScript on the left, resulting JavaScript on the right):
As a Ruby project, you can get the CoffeeScript compiler installed with a simple gem install coffee-script
or check out the code from/on GitHub. The code is worth a look as it's notably quite vanilla with hand crafted Ruby covering the lexer and code generation and Racc built code for the parser.
January 4, 2010 at 11:25 pm
really nice project. in github there is like example the rewrite of underscore,js in coffee
January 4, 2010 at 11:27 pm
For folks who'd like to see where the language is headed, I'd recommend checking out the source and running "rake gem:install" -- I'm hoping to have version 0.2.0 out soon, which includes significant whitespace, object comprehensions, better conversion of statements into expressions, and a whole host of other goodies, most of which you can read about here:
http://github.com/jashkenas/coffee-script/issues/closed
Have fun.
January 5, 2010 at 10:02 am
Hi Peter. Good post - this looks interesting.
January 5, 2010 at 11:36 am
Seems everything in CoffeScript is an object, function is, too. Right?
It's cute!
January 5, 2010 at 5:59 pm
I've created a very simple plugin for using CoffeeScript from Rails, might be useful:
http://github.com/jnicklas/bistro_car
January 6, 2010 at 9:48 am
Juvenn: as in JavaScript, yes, functions are objects.
January 6, 2010 at 6:50 pm
This looks very interesting indeed! Very cool project Jeremy, great post Peter,
January 9, 2010 at 7:07 pm
you have to explain what is the differnce between this and Ruby. i.e why should someone use this new language ? what are the benefits?
January 13, 2010 at 10:25 am
Although Coffeescript feels a bit pythonic, it's a nice idea. Makes me wonder how the various Ruby-to-Javascript compilers are doing.