Tony Arcieri, of Revactor fame, put a bug in my ear about Java ME again this week. He's interested in running Ruby on a device hosting the Connected Device Configuration (CDC) level of Java ME. Specifically, the device in question supports CDC plus the APIs included in the Personal Basis Profile (PBP). CDC is probably about the smallest ME profile JRuby could reasonably run in, since anything lower (like CLDC, the Connected Limited Device Configuration) and you're reduced to the most basic collections, IO, and utility APIs.
So, I'm happy to announce that the JRuby CDC Project has spawned out of the JRuby codebase.
Here's what it looks like running, using Sun's reference implementation of CDC+PBP:
~/cdc/Optimized_nosym$ bin/cvm -classpath ../jruby.jar org.jruby.Main -X-C -e "[1,2,3].each {|i| puts i}"
1
2
3
The "cvm" is Sun's reference implementation of an embedded JVM, and this particular package includes the PBP level APIs as well. The jruby.jar here is the one I've stripped in the jruby-cdc project, but with the additional step of retroweaving it back to Java 1.3-compatible bytecode.
My intention with this is to get it running with a base set of Ruby classes but with Java integration still functional. That will allow most basic Ruby scripts to work while providing access to the rest of the Java APIs for bits I had to rip out (like IO APIs)
It's only running interpreted right now, just like the Android version of JRuby, but as in that case I expect most people will want to precompile Ruby code and ship it all as one unit.
Why bother? Well, there are still a lot of Java ME devices out there. And while the device you carry in your pocket may be growing beyond Java ME, the set-top box or Blu-Ray player in your living room is just starting to reach that level. The technology is still sound, if perhaps less obvious than an iPhone or Android. And hey, we want "Ruby everywhere," don't we?
Where do we go from here? I think this and Ruboto are proof that damn near anything is possible with JRuby. It really only took me a couple days of trimming to get this far. Fully supporting Android in Ruboto will not take long, and other "mini ruby" profiles are possible for other platforms and use cases as well. It just takes a little imagination, and maybe a few late-night hacking sessions.
Now...for my next trick...
Well done. Congratulations on all the JRuby progress recently.
ReplyDeleteCharles,
ReplyDeleteI'd love to see JRuby running on my Windows Mobile device with CreME, an implementation of the CDC profile. Unfortunately it quits starting jruby-1.3 with a NoClassDefFoundError for java.nio CharBuffer from ...retroweaver.harmony.runtime.java.util.Formatter.format(). Seems like retroweaver is not truely converting CharBuffer to Java 1.3 (:
Nice work! Thanks for the post!
ReplyDeleteAny change we get JRuby on a Sunspot?
ReplyDeletehttp://stackoverflow.com/questions/11995975/would-it-be-possible-to-run-ruby-possibly-jruby-on-a-sun-spot-if-so-how