December 29, 2005

To much code

I've just spent the past few days programming a couple of little systems in Ruby on Rails. Then, today I went into to modify a form on our site written in PHP. Simple form: ten fields; straightforward validation; saves to a couple of tables; sends a few emails. Nothing wrong with the PHP code itself.

Except that it takes hundreds of lines. Database calls; validations; display code. All mixed together. What a mess!

In Rails, it'd be only a few lines in a controller + model, plus a view. Much easier to write, and maintain later.

To be sure, not everything is greener on the other side. Some stuff could be easier. The documentation could be better (especially when you get off of the simple CRUD stuff). I'm still wrapping my head around a few concepts, and I'm not super comfortable in Ruby yet. But, that'll come with time. And, perhaps most importantly for our site, Rails is really meant for applications, not one-off pages and forms that are integrated into a larger site. But, so often those one-offs either grow organically into applications, or they represent the tip of the iceberg (the rest of 'berg being an admin system locked away somewhere).