Wednesday, February 28, 2007

XRuby 0.1.2 released

XRuby 0.1.2 is now available for download from the project download page: http://code.google.com/p/xruby/downloads/list

This latest release contains more built-in libraries and a few bug fixes for the compiler. We expect to release a new stable version every month.

Last week, Antonio Cangiano did a very interesting job to compare the performance of different ruby implementations using YARV's benchmark suite. XRuby is not included in his test as Antonio may not know our project exists. For people who are interested, here is the XRuby's performance data (due to my limited resource, only ruby 1.8.5 interpreter was compared):

>java -Xmx512m -jar xruby-0.1.2.jar benchmark\run.rb

TestRuby 1.8.5XRuby 0.1.2
bm_app_answer.rbfailfail
bm_app_factorial.rbfailfail
bm_app_fib.rb20.4233.84
bm_app_mandelbrot.rb7.27015.33
bm_app_pentomino.rb294.2956.9
bm_app_raise.rb4.9064.597
bm_app_strconcat.rb5.9175.858
bm_app_tak.rb26.4638.95
bm_app_tarai.rb21.0835.51
bm_loop_times.rb14.8393.55
bm_loop_whileloop.rb26.2676.5
bm_loop_whileloop2.rb5.32716.15
bm_so_ackermann.rbfailfail
bm_so_array.rb19.35300.2
bm_so_concatenate.rb5.86826.58
bm_so_count_words.rb2.25346.43
bm_so_exception.rb9.8939.973
bm_so_lists.rb3.69641.04
bm_so_matrix.rb6.32821.29
bm_so_nested_loop.rb15.3868.20
bm_so_object.rb21.9720.77
bm_so_random.rb6.26915.69
bm_so_sieve.rb1.9925.476
bm_vm1_block.rb65.6798.91
bm_vm1_const.rb48.0582.31
bm_vm1_ensure.rb46.1975.38
bm_vm1_length.rb55.62105.6
bm_vm1_rescue.rb36.4780.91
bm_vm1_simplereturn.rb57.1288.16
bm_vm1_swap.rb76.2185.73
bm_vm2_array.rb18.6419.65
bm_vm2_method.rb33.4135.32
bm_vm2_poly_method.rb45.4247.78
bm_vm2_poly_method_ov.rb12.8125.98
bm_vm2_proc.rb21.5431.23
bm_vm2_regexp.rb13.4052.35
bm_vm2_send.rb11.8731.60
bm_vm2_super.rb13.9820.25
bm_vm2_unif1.rb11.4619.95
bm_vm2_zsuper.rb15.8421.92
bm_vm3_thread_create_join.rb0.1201.402


The test environment is Intel Pentium M 1G CPU, 1G Memory, Windows XP SP2, Java 1.5.0_09. It may be worth to mention we have done almost nothing for optimization, not even a simple method cache. I think it is quite possible for a JVM based ruby compiler to beat the classic Ruby interpreter on performance, while YARV's number is going to be very hard for us to reach.

Sunday, February 18, 2007

On-Ruby interview


Pat Eyler recently interviewed XRuby team, the first episode is now posted on his popular On-Ruby blog: http://on-ruby.blogspot.com/2007/02/serial-xruby-interview-episode-i.html

Monday, January 29, 2007

XRuby 0.1.0 released


[Link of this article: http://xruby.blogspot.com/2007/01/xruby-010-released.html]

Today I am glad to announce the release XRuby 0.1.0 , a ruby compiler which compiles ruby script (.rb) to java bytecode (.class). You can download it from here: http://code.google.com/p/xruby/downloads/list

XRuby 0.1.0 is the first release of XRuby. It is able to pass all tests in samples/test.rb - a decent test suite that comes with ruby installation.

As a compiler, XRuby compiles ruby source code so that your program can run on top of Java Virtual Machine. For example, if you have a ruby script like this:

class MyClass
  def say_hello_three_times
    3.times {puts "hello"}
  end
end

MyClass.new.say_hello_three_times


You can compile it with XRuby (assuming its name is test.rb):

>java -jar xruby-0.1.0.jar -c test.rb

The compiler will generate a test.jar. It can be launched as a regular java application, with the following command:

>java -jar test.jar
hello
hello
hello


For your convenience, you can also run the script directly (without -c option), just like the classic ruby interpreter. Under the hood it compiles the script then run the bytecode:

>java -jar xruby-0.1.0.jar test.rb
hello
hello
hello


While little known, this project has been under active development for one year and eight months. I started the project around mid 2005, and it took me about eight months to write a ruby parser with Antlr, and then one year to implement the compiler and runtime. Some people joined me during the second half of 2006 and made great contribution. It is just the beginning of an exciting journey.

We still have a long way to go before claiming XRuby is a very competent alternative implementation of ruby. And comparing with our peers we lag behind in implementing ruby's built-in libraries and do not have Ruby-Java bridge. Our next focus is to improve this situation and make major ruby libraries and framework work under XRuby. And we hope by end of 2007 you can use XRuby to compile your Ruby On Rails application to a .war file and run it directly on a J2EE server.

We appreciate your feedback. Our development maillist is at: http://groups.google.com/group/xruby-devel.

I also setup a new blog to be used as XRuby's team blog: http://xruby.blogspot.com . While new articles will be cross posted for quite a while, I encourage you to subscribe http://feeds.feedburner.com/xruby if have not done so.

Thank you and have fun.