CoffeeScript: A New Language With A Pure Ruby Compiler

In Cool

coffeescript.png 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.

To get a feel for the language, check out this example code (CoffeeScript on the left, resulting JavaScript on the right):

cofeescriptdemo.png

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.

Vaguely Related Posts (Usually)

9 Comment Responses to “CoffeeScript: A New Language With A Pure Ruby Compiler”

  1. #1
    sasuke Says:

    really nice project. in github there is like example the rewrite of underscore,js in coffee

  2. #2
    Jeremy Ashkenas Says:

    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.

  3. #3
    Ric Roberts Says:

    Hi Peter. Good post - this looks interesting.

  4. #4
    Juvenn Woo Says:

    Seems everything in CoffeScript is an object, function is, too. Right?
    It's cute!

  5. #5
    Jonas Nicklas Says:

    I've created a very simple plugin for using CoffeeScript from Rails, might be useful:

    http://github.com/jnicklas/bistro_car

  6. #6
    Benedict Eastaugh Says:

    Juvenn: as in JavaScript, yes, functions are objects.

  7. #7
    Zach Dennis Says:

    This looks very interesting indeed! Very cool project Jeremy, great post Peter,

  8. #8
    batman Says:

    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?

  9. #9
    Beoran Says:

    Although Coffeescript feels a bit pythonic, it's a nice idea. Makes me wonder how the various Ruby-to-Javascript compilers are doing.