Notes from TheServerSide Java Symposium, March 2009
Why Ruby? He talks about the known good language features, but the biggest reason is Rails. Ruby is actually an older language than Java.
JRuby 1.1 incorporates a just-in-time (JIT) compiler, and in many tests is faster than the Matz Reference Implementation.
In answer to a question, JRuby would exclude some gems that incorporate native extensions, but many gems are beginning to include Java native extensions.
JRuby can incorporate and use Java classes in four different ways, and the implementation lets you use Ruby-native syntax for accessors.
|emp.setName(“Homer”);||emp.name = “Homer”|
Camel case Java names can be called with underscores, i.e. url.to_external_form vs. url.toExternalForm().
He then gave examples of language features, including closures, open classes, shadow meta-class, modules a.k.a. mixins.
Because of the dynamic nature, tests are not optional in Ruby projects. Being interpreted, tests need to find runtime errrors.
You can do Swing in Ruby, but it’s a little weird. Fun to be able to reopen classes and modify behavior. There’s an open-source framework, swiby = jruby + swing.
Very interesting use case: using JRuby to run Java tests. Making mock objects in Ruby is right in the language’s sweet spot, whereas mocks in Java require all kinds of perverted twists to make Java do what it doesn’t want to do, and create types.
I guess Ruby is beautiful if you’re deep into meta-programming, partly because it makes it easy. It doesn’t take a lot of code to do what you want to do.
He states that while JRuby is at least as fast as native Ruby, JRuby is profoundly slower than Java, in exchange for faster development time.