Saturday, November 19, 2005

Cornucopia complex, Ruby on Rails vs. Java and Lisp

"Cornucopia Complex" is an old joke of mine: fear of too many good things :-)

I claim to be program language agnostic (best tool for the job, etc.) but that is not strictly true because given sufficient libraries of pre-built code, I would just about always choose to program in Lisp. The point here is that existing infrastructure software continually drives me to one language or another. Java usually wins big here with tools like Tomcat, Lucene (including that fantastic Nutch project - I have been using Nutch in the last week - great stuff!), Hibernate, etc.

But Java does not win hands down: Ruby on Rails gets more compelling the more I use it. Seriously, compare using one of the Java AJAX frameworks with the simplicity of in RoR just including the prototype Javascript library in a RHTML template, and using link_to_remote, form_remote_tag, etc. On the Ruby side, a controller class action simply returns HTML with full access to form values using params[], etc. The first time I saw this in Curt Hibb's "Ajax on Rails" tutorial I couldn't believe how simple AJAX could be. Amazing what a single clean architectural framework will do for you.

The real deal would be to easy integration between Java for infrastructure code and RoR for web application user interfaces, and there are certainly easy ways to do this with plain old sockets, XML-RPC, SOAP (uh, a little too heavyweight for me usually), REST, shared database access, etc.

A few years ago, I got enthusiastic about Python and was initially excited by the prospect of natively compiling libraries like Lucene using the GNU gcj compiler, CLASSPATH, etc. and linking with Python (I used this for a while on OS X, but the shared library for natively compiled Lucene and all required libraries was huge). Same could be done for Ruby. However, that just seems wrong to me - I would rather have a Java JVM process and a Ruby (or Python, or Common Lisp) process and use socket, RPC, etc. Socket I/O on the same server is efficient to the point of just about being free anyway. Platform selection seems to be getting easier: if I need a major piece of Java infrastructure software (like Lucene), then I would choose Java. For most other web applications, I would choose RoR. If I had lots of time, I might choose Lisp and build up my own platform - but I think that this would be cost effective in few projects.

No comments: