JRuby
One of the cooler things that was presented today at GoRuCo2007 was a talk by Nick Sieger on JRuby. JRuby is a somewhat complete implementation of Ruby in Java.
Like most talks I have seen given, it wasn’t so much the talk itself that was informative, it’s was the piquing of interest in the topic that made the difference. After listening to what Nick had to say, I was interested in checking out what JRuby had to offer.
Installation in Ubuntu was easy peasy.
mkdir /usr/local/bin/jruby
svn co svn://svn.codehaus.org/jruby/trunk/jruby /usr/local/bin/jruby
export JRUBY_HOME="/usr/local/bin/jruby"
cd /usr/local/bin/jruby
ant test
That does assume that ant is installed, configured and in your path, but that is another topic…on my system it already was (Though I haven’t messed with Ant or Java in a long time, so I don’t remember why it was set up already).
After that it’s a simple matter of trying it out (I found this example on the web site for JRuby).
require 'java'
include_class 'java.util.TreeSet'
set = TreeSet.new
set.add "foo"
set.add "Bar"
set.add "baz"
set.each do |v|
puts "value: #{v}"
end
Then from the command line:
jruby test.rb
Badabing, it runs
value: Bar
value: baz
value: foo
Give it a whirl…it’s neato.
Hey Nathan, thanks for the kinds words! Glad to hear your initial experience w/ JRuby was positive. If you ever have a practical application for JRuby and have a question, don’t hesitate to send me a note.
Nick, thanks and will do.
My mind is already going over some possibilities.
I think the fast track you folks have put development on bodes well for JRuby’s success. Keep up the good work.