Monday, March 24, 2008

Google Summer of Code with Ruby Central

Ruby Central will once again participate the Google Summer of Code in 2008 as a mentoring organization:
http://code.google.com/soc/2008/ruby/about.html

Pat Eyler has put together an idea page, which is a great reference. While every organization may have different policy, Ruby Central has been happy to see students' own ideas in the past, and I believe this year is not an exception. Feel free to submit your own exciting ideas so that the mentors can pick the best ones.

Today is the first day for Google to accept student applications. For student who are interested in participating, my advise is to apply as early as possible: normally students who apply early has a slight advantage because mentors will have more time to read their applications.

And another advise for future GSOC students is: once accepted, please make sure you are well prepared for the program. Google and mentors normally assume you to work near fulltime in the summer, but unfortunately every year we saw 'disappearing' students during the program. If for some reasons you can not make it after being accepted, please communicate with your mentor organization early so that they can make better adjustment.

XRuby license changed to BSD

XRuby had been licensed under GNU General Public License v2. For people who want to create solutions based on XRuby, this means they had to adopt GPL as well, which is not always possible. So since 0.3.3, we changed the license to BSD. Hopefully this will help XRuby gain more acceptance, especially from the corporate world.

Monday, September 24, 2007

XRuby 0.3.1 released

XRuby 0.3.1 is released today and you can download the latest version here:
http://code.google.com/p/xruby/downloads/list

The major changes in this version are:

1. Ruby standard libraries are now pre-compiled and the compilation results (java bytecode) are shipped as part of the xruby.jar. This makes deployment really easy, as there is one jar file to deal with. Pre-compiled libraries means it isn't necessary to compile these code every time by the user which is helpful to performance.

The size of the final jar may cause some concerns: while the number of ruby stdlib supported by the current version of XRuby is still limited, the size of the compiled stdlib has already reached 2,000 KB (the entire xruby-0.3.1.jar is over 4,000 KB). Maybe we will ship ruby stdlib in a separated jar files in the future.

2. Use annotation and code generation to bind Java level method to Ruby level method. We started to make this change in 0.3.0 and finished it in 0.3.1. It helped us to get rid of lots of redundant code. For more information about this change, please read our last announcement and dreamhead's articles(1, 2) on his blogs (in Chinese).

Thank everyone who has contributed to this release.

Tuesday, August 7, 2007

xruby 0.3.0 released

I am pleased to announce that XRuby 0.3.0 is released:
http://code.google.com/p/xruby/downloads/list

We have fixed lots of bugs and made significant improvement in the code.

Changes from 0.2.1 to 0.3.0:
1. Use annotation and code generation to bind Java level method to Ruby level method (I will talk more about this later).

2. More unit tests passed. We have not eliminated all test failures in test/ruby. But as most of the failures are caused by the implementation of builtin libraries, we will be able to fixed them soon in 0.4.0.

Changes from 0.2.0 to 0.2.1:
1) Dreamhead optimized method/block calls for methods with zero/one
arguments. It makes our performance even better.

2) ZhangYu improved Java integration significantly, he also created a wiki page with lots of good examples:
http://code.google.com/p/xruby/wiki/JavaIntegration

3) Mechiland and I made more ruby unit tests pass.

The most significant change of 0.3.0 is the using of annotation and code generation to bind Java level method to ruby level method. The idea was inspired by the discussions about Java 5 on jruby's maillist, and dreamhead turned it into reality quickly.

As we know, a Ruby method does a little bit more than a Java method. So if we have a method like this in Java:

public class RubyString {
public RubyFloat to_f() {
...
}
}
To turn it (RubyString.to_f) into a Ruby level method, we have to add a few more code to 'wrap' into a class (extends RubyMethod) and 'register' it (defineMethod), e.g:
public class String_to_f extends RubyNoArgMethod {
protected RubyValue run(RubyValue receiver, RubyBlock block) {
return ((RubyString)receiver).to_f();
}
}
...
RubyRuntime.StringClass.defineMethod("to_f", new String_to_f());
For every method, we need to write similar code and it is not fun to repeat yourself. In 0.3.0, we no longer have to do this anymore. As as long as you add annotation like this:
@RubyLevelClass(name="String")
public class RubyString {
@RubyLevelMethod(name="to_f")
public RubyFloat to_f() {
...
}
}
XRuby will turn it into a Ruby level method automatically (using ASM to generate Java bytecode).

I have not used Java 5's annotation feature before, but this looks like an very elegant solution.

Thank everyone who has contributed to this release.

Tuesday, June 12, 2007

ruby -y

For people who are interested in how ruby's yacc parser works, there is an undocumented command line option("-y") that may be helpful. It will display a trace of the parser's operations.

To use it, you need to clear your RUBYOPT environment variable to NOT use "rubygems" (this will break some ruby applications), otherwise it will make too much noise.

Here is an example:


$ruby -y -e "a=1"
Starting parse
Entering state 0
Reducing stack by rule 1 (line 328), -> @1
Stack now 0
Entering state 2
Reading a token: Next token is token tIDENTIFIER ()
Shifting token tIDENTIFIER, Entering state 34
Reading a token: Next token is token '=' ()
Reducing stack by rule 418 (line 2146), tIDENTIFIER -> variable
Stack now 0 2
Entering state 90
Next token is token '=' ()
Reducing stack by rule 83 (line 827), variable -> lhs
Stack now 0 2
Entering state 73
Next token is token '=' ()
Shifting token '=', Entering state 315
Reading a token: Next token is token tINTEGER ()
Shifting token tINTEGER, Entering state 40
Reducing stack by rule 414 (line 2134), tINTEGER -> numeric
Stack now 0 2 73 315
Entering state 89
Reducing stack by rule 376 (line 1899), numeric -> literal
Stack now 0 2 73 315
Entering state 79
Reducing stack by rule 267 (line 1421), literal -> primary
Stack now 0 2 73 315
Entering state 75
Reading a token: Next token is token '\n' ()
Reducing stack by rule 217 (line 1199), primary -> arg
Stack now 0 2 73 315
Entering state 488
Next token is token '\n' ()
Reducing stack by rule 173 (line 953), lhs '=' arg -> arg
Stack now 0 2
Entering state 74
Next token is token '\n' ()
Reducing stack by rule 40 (line 616), arg -> expr
Stack now 0 2
Entering state 64
Next token is token '\n' ()
Reducing stack by rule 34 (line 596), expr -> stmt
Stack now 0 2
Entering state 63
Next token is token '\n' ()
Reducing stack by rule 6 (line 381), stmt -> stmts
Stack now 0 2
Entering state 62
Next token is token '\n' ()
Shifting token '\n', Entering state 216
Reducing stack by rule 496 (line 2429), '\n' -> term
Stack now 0 2 62
Entering state 220
Reducing stack by rule 497 (line 2432), term -> terms
Stack now 0 2 62
Entering state 300
Reading a token: Now at end of input.
Reducing stack by rule 489 (line 2416), terms -> opt_terms
Stack now 0 2 62
Entering state 299
Reducing stack by rule 4 (line 373), stmts opt_terms -> compstmt
Stack now 0 2
Entering state 61
Reducing stack by rule 2 (line 328), @1 compstmt -> program
Stack now 0
Entering state 1
Now at end of input.


XRuby's ANTLR parser does not have this option. But as ANRLE produces human readable code, you can just read the generated code or step through it in a debugger to learn how it works.

Tuesday, May 15, 2007

XRuby 0.2.0 released

I am glad to announce that XRuby 0.2.0 is now available for download at:
http://code.google.com/p/xruby/downloads/list

Here is a summary of major changes in this release:

1. Beanworms started to work on the debugging support and we now have a basic debugger in trunk.
2. Zhang Yu and Haofei Wang added/fixed lots of builtin methods
3. Dreamhead rewrote RubySymbol as the old one was plain wrong
4. As test::unit works on XRuby, we imported unit tests from c ruby (test\ruby) to test our implementation. The result was not very impressive so far, less than half of the tests passed. We are planning to make all tests pass in the coming weeks.
5. Meanwhile, Femto is leading our efforts to create an ANTLR v3 based ruby parser in another branch. Upgrading our parser from ANTLR v2 to v3 is indeed challenging, but he has make very impressive progress.

Thank you everybody who contributed to this release!

Tuesday, April 17, 2007

InfoQ article on XRuby

Werner Schuster from InfoQ has a very nice article about XRuby, you can read it here.

UPDATE 04/27/2007: InfoQ China had an interview with our core developer Dreamhead. You can read it here (in Chinese). And congratulations to Dreamhead for joining Thoughtworks.