rb2js/Ruby to JavaScript

About

The rb2js project has its roots in the proof-of-concept Ruby to JavaScript converter which I posted to the ruby-talk mailing list a few weeks ago.

So far, all work is being done by me, Paul Battley. See below if you’d like to get involved in some way.

Current status

The first hurdle, converting a subset of Ruby code into working JavaScript, has already been achieved. However, it requires specially-written Ruby code. We can do better.

The next stage involves creating a close approximation of a Ruby object and class system in JavaScript.

I’ve now got a basic Ruby object system working in JavaScript. I’ve also implemented some basic String and Kernel methods so that the following JavaScript code actually works:

var s = RbString.box('Hello');
rbSendMessage(s, '<<', [' World']);
rbSendMessage(RbRootObject.getConstant('Kernel'), 'puts', [s]);

It’s analogous to this in Ruby:

s = 'Hello'
s << ' World'
Kernel.puts(s)

Instantiation isn’t yet possible except in the special case of boxed strings. Implementing Class properly is the next major step.

Get involved

The current code is available via Subversion:

svn co svn://rubyforge.org//var/svn/rb2js/sandbox

If you’d like to help or just follow along, please join the mailing list.

Contact

Send an email to pbattley@gmail.com.

Paul Battley, 20th July 2006