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:
|Language||Last Run Took||Total (Real) Time|
|Ruby||0.776 sec||7.798 sec|
|JRuby||0.259 sec||3.964 sec|
|RubyFlux||0.044 sec||0.756 sec|
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.
Github link is now https://github.com/headius/rubyflux , not https://github.com/headius/fastruby
Nice article! I always like to hear about innovation in the Ruby community.
Thanks Andrew. The rename was in-progress when I wrote this. The link has been updated.
There already is a RubyMotion for Android (sort of): http://ruboto.org/
Not completely the same scope, but a nice project.
You’re right, Ruboto does allow for ruby to run on Android. However it has some fundamental differences. Ruboto uses JRuby to interpret your Ruby code and has a hefty overhead of both startup and runtime performance. RubyFlux, on the other hand, statically compiles your ruby code ahead of time into pure Java. That means no runtime dependencies, no start-up overhead, and pure Java performance.
That’s why I said “sort of” :)
But you are right of course: Once RubyFlux gets full access to the (Andoid) Java-API, it can really become an interesting alternative, especially for heavy load apps.
TL;DR – I love this section, but I have to wonder why it isn’t written first? (it is after all simply an abstract)
It’s a great article, except at that, which I agree with you. TL;DRs should be at the top. It doesn’t mean the article won’t be read. Actually it can captivate the reader the same was an introduction or caption does.
The TL;DR has now moved to its proper place at the top of the article. Thanks for the feeback.
There is a mailing list now, if anyone is interested: https://groups.google.com/forum/?fromgroups#!forum/ruby_flux
Comments are closed.