Precompiling Ruby...completely

I wrote up a blog post about my evening’s experiments precompiling
Ruby to JVM bytecode:

The short of it is that I’ve added --sha1 and --handles flags to
jrubyc (on master only…we need to talk about whether it should get
into 1.5 final).

–sha1 makes the jrubyc compiler produce sha1-named class files, which
in turn makes it possible to locate them regardless of how they’re
loaded (i.e. if you require ‘bar/baz/foo.rb’ or require
‘…/yummy/…/foo.rb’ it will still find the compiled code). This is
the first piece needed to get precompiled sources to load consistently
from Java classloaders.

–handles forces the compile process to spit out at compile time the
“handle” classes it would normally generate at runtime. This means
that for method bodies, no additional code generation needs to happen
at runtime (which doesn’t work on Android and slows things down on
Google AppEngine).

I still need to make --handles work for binding block bodies, but that
won’t be difficult.

At any rate, this brings us 90% of the way toward being able to
completely precompile Ruby code for any target environment. Read the
blog post for more details on current issues and needed improvements.

  • Charlie

To unsubscribe from this list, please visit: