Monday, April 21, 2008

Ruby Red or Saphire Blue?

I've recently started revamping a project at work for collecting subjects. The basic premise being a lab member fills out a template of what they want to ask for their specific study. This gets posted as a link when advertising new studies (/subject_collector/, etc.). The main problem with the initial version of the project wasn't this part(aside from preventing replica submissions it works just as intended); it was that the researcher that requested it was already comfortable with MySQL so he was willing to use his own SQL queries on the database I designed. This is all well and good until other people start asking for access to the system. Hence the redesign, or more specifically expansion to include an administrative back-end. Including user authentication, deletion of subject by study or removal of the subject entirely from that researchers subject pool (and preserving the subject if they are in other subject pools).

The Red Pill:
Luckily Ruby's 'route.rb' file allows for fairly robust path handling that makes it pretty simple to issue a new link to a new area of the website. This makes adding new 'stuff' to a website pretty easy overall even for a newbie like me. In fact the one major failing I've noticed so far is there are no clear cut ways to do authentication of users, something I figured would have been worked out by now (rails has reached version 2.0, this should well and done by now).

Ruby's syntactic sugar also goes a bit to far sometimes. It 'almost' gets in the way because it's not always easy to predict which edge of the sword you need to be playing with at a given time. This is something that I'm sure gets more predictable when you've used the language for a few projects but it gets in the way a bit when your adopting the new programming paradigm.

These issues aside, if I can achieve the flexibility that ruby on rails affords me with something that has more explicit object mapping like python I'd probably head in that direction. I'm not entirely comfortable mincing words with a JIT compiler over whether I've properly pluralized a word, or if I even need to pluralize the word in a give instance or location; so working around that problem entirely would definitely be the preferred path from here on.


The Blue Pill:
The reality of the situation is that it really doesn't matter what you make your website out of and it's more dictated by how dynamic your infrastructure is. If your using a windows server, something .net would probably be more your speed, thou a ruby 'mongrel' and virtual server (this is far preferred for cgi/fast-cgi, as the performance there is horrid) implementation certainly wouldn't let you down in the long run. Thou I have had some stability problems with mongrels on our production Linux machine, every now and then they decided they'd rather go bake cookies than actually do work. To remedy this I have them perform a rolling restart ever 2-4 hours (I actually don't recall what it's set to right now..), the disadvantage being that my mongrels are down for a few seconds. However this is countered by the fact that if they go to bake cookies they apparently fall into the oven and never return.

On the other hand if your using a Linux machine
to publish your work too you can easily setup apache to do whatever you want (this is also true in Windows and on the OSX platform). I would still stear clear of the cgi/fast-cgi implementations and go straight to the ruby mongrel style solutions. However any of the above solutions will work and on a smaller project it won't really matter which one you choose; bare in mind you can always change latter. I assume this holds true for the mac as well but I haven't tested it, if they ever expand their licensing to run VM's on other hardware I'll kick the ball around the court.

All in all however I think if I can find a way to do this using python, I'll most likely row in that direction for future projects. The 'genshi' template system from the people that make Trac is a step in the right direction but not a single 'goto' solution like ruby. So more research to be done before I find something I'm comfortable with I guess.

0 comments: