Friday, September 21, 2007

Rails to Trails

Besides being the name of a great organization that preserves railroad right-of-ways for bike paths, this phrase is apt to describe my recent experiences with lightweight web development frameworks for the Ruby programming language. The bike trail blog entry will have to wait for another day.

I'm doing some tools software developers at my work will be using these days, and I've been trying various web application frameworks to see which meets my needs the best.

I started with Ruby on Rails (that would be the "rails" part). I'm pretty familiar with that tool already, having hosted UtahFEAT.org using it for a couple of years now. It does a great job of making ORM (object-relational mapping) easy, so that you can use object-oriented programming methods on data in a relational database. And it does it very well IF you are able to control the schema and follow certain very stringent conventions. For this project, that was not really an option, and I wanted something more simple anyway.

I then packed up my things and went Camping. Camping is a "microframework", smaller and more lightweight than Rails (which is fairly lightweight already... compared to Java's J2EE, for example). Camping springs from the mind of the venerable and hilariously idiosyncratic Why the Lucky Stiff. It's built around ActiveRecord (the ORM discussed earlier, from Rails) and (by default) SQLite. Not a bad microframework, a nice alternative to Rails. I didn't want ORM, and I did want *.rhtml files (like .jsp's in Java). In the end, I found Camping nice, but not a great fit for what I wanted. Plus it was, well... idiosyncratic.

What's left then? Blaze my own trail, I suppose. I thought I had hit a brick wall until I experimented more with WeBRICK and the erb library... waka, waka. If you're used to Java servlets and .jsp pages in J2EE, this is probably the least-shocking and simplest way to make a web application in Ruby. You can write an MVC (model-view-controller) application on what I'm calling "TRails" ("Trivial" Rails?) in just a few lines of code, with or without a database.

Of course, while I was figuring this all out and banging my head over Linux database package dependencies, my co-worker implemented it very simply with .jsp's. Ay, caramba! To quote a RUSH song (for the second day in a row): "the point of a journey is not to arrive", but to enjoy the "long and winding road" (okay, that's the Beatles).

No comments: