Android and JRuby (1)
Well, i’ve delved into it a little more – specifically i’ve watched presentation by Charles Nutter about the JRuby compiler, and tried to dx (transform the bytecode to fit the Dalvik Virtual Machine) a simple jruby compiled class.
jrubyc mvm.rb
dx --dex --output=mvm.dex mvm.class
I couldn’t actually test this (except performing a dump) on the virtual machine – something missing from the android toolset here, for as far as i could see.
(other interesting writeup about the DVM here)
I don’t really know much about compilers, but my intuition is that this might not work:
- The compilation of JRuby code transforms the structure beyond recognition – lots of ‘method’s are created to compensate for Ruby’s dynamic nature. My impression is that Android expects certain predefined classes (Activity, Intent and whatnot) – extending those classes with JRuby might produce something totally different, and ultimately unuseable.
- Even if it works, the use of Ruby might be severely constrained – no Ruby magic, weird inclusions etc. Actually, would there be a point to making this work at all ?
Anyhow, these are initial impressions. I’ll need to experiment with Android some more, and then test some with both (JRuby and android) toolsets. I might also be in over my head, and this might require language expert intervention. Live and learn, right ?
The cool thing is that it’s the Android SDK which “expects” a certain structure. Dalvik doesn’t. As soon as you get jruby to compile to dalvik bytecode instead of java bytecode you would be able to start doing simple “Hello World” stuff which would certainly be a start
I’m aware of this – however, the whole idea is to run something on the Android platform
otherwise, there isn’t much point (except theoretical interest maybe)