Charles Nutter has announced that JRuby has a functional compiler
now, that is able to "dump the stdlib.rb files and continue running nontrivial applications like IRB or RubyGems." There's also another compiler in the works, that will be able to generate a normal Java class, usable with standard Java semantics.
For the first time ever, there is a complete, fully-functional Ruby 1.8 compiler. There have been other compilers announced that were able to handle all Ruby syntax, and perhaps even compile the entire standard library. But they have never gotten to what in my eyes is really "complete": being able to dump the stdlib .rb files and continue running nontrivial applications like IRB or RubyGems. I think I'm allowed to be a little proud of that accomplishment. JRuby has the first complete and functional 1.8-semantics compiler. That's pretty cool.
What's even more cool is that this has all been accomplished while keeping a fully-functional interpreter working in concert. We've even made great strides in speeding up interpreted mode to almost as fast as the C implementation of Ruby 1.8, and we still have more ideas. So for the first time, there's a mixed-mode Ruby runtime that can run interpreted, compiled, or both at the same time. Doubly cool. This also means that we don't have to pay a massive compilation cost for 'eval' and friends, and that we can be deployed in a security-restricted environment where runtime code-generation is forbidden.
On the second compiler:
Compiler #2 will basically take a Ruby class in a given file (or multiple Ruby classes, if you so choose) and generate a normal Java type. This type will look and feel like any other Java class:
The basic idea behind this compiler is to take all the visible signatures in a Ruby class definition, as seen during a quick walk through the code, and turn them into Java signatures on a normal class. Behind the scenes, those signatures will just dynamically invoke the named method, passing arguments through as normal.
- You can instantiate it with a normal new MyClass(arg1, arg2) from Java code
- You can invoke all its methods with normal Java invocations
- You can extend it with your own Java classes
This is great news - one of Jython's unique features
is the ability to generate .java files from Python code through jythonc
, although this feature is going away. It's good to see that another project is taking up the banner of being able to take a scripting language and generating classes usable from idiomatic Java.