I’m going to write a bit about Ruby in Java land. Much of this post stems from the Sun stall at FOSS.in: to put it mildly, it was perhaps the most enthusiastic stall I’ve seen at a conference ever. The energy of the guys there was incredible and their enthusiasm to show things off (and Sun does have a lot of nice things to show off: dtrace, ZFS, glassfish) really made me give a second glance to the entire Java + Ruby thing: JRuby, or a Ruby implementation in Java, and Rails deployment via the Java Enterprise stack. I’ve been playing around with it for a day, and I’ve got just one thing to say. It’s cool 🙂
A bit of a background: I’m not a Java guy. Repeat, not a Java guy. So when people say that the Java toolset is amazing, I’ve always not understood what they meant. Who needs toolsets, widgets, a GUI, an administrative console; when you’ve got SSH & shell scripting? The last four months developing SlideShare however, have been a bit of a revelation: managing servers is a tough job. Our current stack includes a lighttpd->pound->mongrel chain, and monit to watch these processes and start them off if something goes wrong. Lots of glue code, and solutions that seem hacks now (a separate uploader mongrel, anyone?). Anyways, the role of a sysadmin sucks: big time, and the toolsets to manage a traditional *nix environment requires too much of manual work. [Stuff such as Puppet might negate this, but I digress…]. So it was kinda really nice to switch on Glassfish, drop a .war into an autodeploy directory and watch the application come alive. And have an actual GUI console to manage all this stuff, read up on the logs, configure routes & services, etc.
I’ve not done much: just installed Glassfish, played around with asadmin start-domain domain1
and the console, and then installing Jruby and the easy Java + Ruby integration. Look at this code, for e.g.:
#!/usr/bin/env jruby require 'java' set = java.util.TreeSet.new set.add "foo" set.add "Bar" set.add "baz" set.each do |v| puts "value: #{v}" end string = java.lang.String.new string = "Vishnu" puts string
Sweet ain’t it? One of Ruby’s selling points has always been that it’s easier to drop into a low level language (C) and write extensions for expensive functionality, thus negating Ruby’s slow performance. But stuff like the code sample above should make it pure nirvana for expensive operations. I haven’t compared speeds yet: I’ll do that soon using a simple Web framework like Camping & then a simple Rails app (i.e. Camping/WebBrick on Ruby and JRuby and Camping/Mongrel vs Camping/Glassfish: if I can get it running). JRuby isn’t perfect yet: Rails applications aren’t officially supported, but I hope to get a useful app deployed on localhost soon, and if there’s interest, deploy it to my slice. It’s an upward slope though for me, since the whole Java deployment scene [making a WAR] seems so bloody complicated (why, oh why?) but a good indicator for good Ruby/Rails deployment on JRuby would be to just type in rake deploy
and have your code get into the whole Glassfish stack.
Leave a Reply