Friday, September 28, 2007

Trying out jrubyc

Following up the good news, I pulled down trunk, and compiled a stupid 2 line script. This obviously is no test of the compiler, but the first time I've used jrubyc. Above and beyond the normal JRUBY environment stuff, to execute classes you have to add jna.jar and jruby.jar to your CLASSPATH.

franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ java bobo
franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ ls -al bobo.class
-rw-r--r-- 1 mdfranz mdfranz 2866 Sep 28 09:43 bobo.class
franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ cat bobo.rb
franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ echo $CLASSPATH
franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ echo $JRUBY_HOME

Wednesday, September 26, 2007

If you are angry enough you might get a book!

So I was pleased to learn that I will be receiving a review copy of Practical JRuby on Rails Web 2.0 Projects: Bringing Ruby on Rails to Java. Thanks Ola if you had anything to do with it!

No time (and probably not qualified) right now to do a real review, but I will say that Chapter 6 (Java Integration) and the Appendix B (JRuby Reference) are probably worth the 21 bucks for the e-version of the book, even if you don't plan on doing any JRoR work right now.

Tuesday, September 25, 2007

JRuby Enum Constants and my irrational fear of ::'s

So development on PeerTAB is rolling along. Sort of. I am continuing to play with JXTA via JRuby.

So in Java
manager = new NetworkManager(NetworkManager.ConfigMode.EDGE, "HelloWorld");

But of course in JRuby
include_class "net.jxta.platform.NetworkManager"
m =, "HelloWorld")

fails with

irb(main):010:0> NetworkManager.ConfigMode
NoMethodError: undefined method `ConfigMode' for Java::NetJxtaPlatform::NetworkManager:Class
from (irb):10:in `binding'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:150:in `eval_input'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:70:in `signal_status'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:70:in `each_top_level_statement'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:146:in `loop'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:146:in `catch'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:70:in `start'
from :1:in `catch'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:69:in `start'
from :1

So the question then I how do I get these enum constants?

So interestingly enough

irb(main):020:0> NetworkManager.constants
=> ["ConfigMode"]

But that did get me anywhere and it was only until I ran across this blog post that I figured it out.

irb(main):011:0> NetworkManager::ConfigMode
=> Java::NetJxtaPlatform::NetworkManager::ConfigMode
irb(main):012:0> NetworkManager.constants
=> ["ConfigMode"]
irb(main):013:0> NetworkManager.constants.class
=> Array
irb(main):014:0> NetworkManager::ConfigMode::EDGE
=> #

And I know part of the problem is I refuse to use :: unless I'm forced to because it seems way too Perl-ish and ugly. And yeah, I've heard there is something called C++.

Monday, September 24, 2007

Interesting Bruce Tate Podcast

I listened to Robert Stephenson's interview with Bruce Tate while washing dishes tonight and it was certainly a treat and certainly kept my mind occupied while cleaning up the minestrone remnants:

Among the highlights:

  • How development in Rails (and I would add comparable frameworks such as Django) allows smaller teams to communicate more effectively (and frequently) with clients than would be possible with "traditional" languages such a Java.
  • The high correlation between offshoring/outsourcing and traditional (waterfall) development models (if you outsource something you have to be more rigorous in the your specification, your unit testing, integration, etc.)
  • Lots of talk about JRuby and positing that much of the work we do is essentially scripting. Use of JRuby with Business Rules Engines/DSLs (such as Drools) which is something I've wanted to play around with yet. As well as using a Java scripting languages to access cool APIs.

Check it out...