Charles Nutter, creator of JRuby, has a new offering for the Ruby/Java community: RubyFlux (formerly called fastruby). RubyFlux is a static Ruby to Java compiler. It uses JRuby to analyze the AST of the Ruby files and generate Java source files. The generated code has no run-time dependencies and ends up being pure Java.
RubyFlux could be an amazing tool if/when it gets built into a usable state. It provides massive speedups over MRI or even JRuby.
Here’s a preliminary benchmark. It generates a Mandelbrot Set ten times to compare the native Ruby to the much faster RubyFlux. Here are my results:
|Last Run Took
|Total (Real) Time
Ruby took almost 8 seconds, and RubyFlux took less than a tenth of a second! It’s just pure Java code running.
RubyFlux will make your Ruby code able to run on any JVM without any run-time dependencies. So, what’s the catch? It’s not ready, and there will be limitations when it is. The project exists mostly as a tech demo or function proof-of-concept; it has a long way to go before it will be production ready. It does not have a working test suite and is missing large pieces of Ruby functionality, including supports for blocks. There’s also no mechanism for calling into existing Java libraries, but Nutter says that’s next on the list.
When finished, RubyFlux will be a subset of Ruby in the same way that RubyMotion is. Some of the most dynamic pieces of Ruby may not be there.
It’s not done yet, but RubyFlux shows great promise in getting serious Ruby development in places like Android or embedded applications. With some work, it could be the Android equivalent to RubyMotion.
RubyFlux statically compiles Ruby into Java. It has awesome performance and runs everywhere Java does with no runtime dependencies, but it isn’t done yet.