Riding the Rails
August 21, 2007No longer should the secret be kept from whoever is reading this: I want to marry Ruby and have its sweet, lovable babies. By the way, I’m also rather confident Ruby will think of a quick and easy way for a man to bear children, so that I can keep my promise. I mean, if it’s able to create a working blog in just 15 minutes and using just 58(!) lines of code, then this should prove to be a piece of cake.
Those of you who cared enough to visit the links above have by now probably noticed I’m talking not just about Ruby, but also (and mainly) about Ruby on Rails. First off, a bit of history to get us in the mood: Ruby was developed in 1993 by Yukihiro Matsumoto, and released to the general public in 1995. It was designed to be an elegant and easy language, which does exactly what we expect it to do; methods are named after English terms that appropriately define the action it performs.
However, it was only in 2003, when David Heinemeir Hansson, together with 37Signals looked into coding a web-based project management tool, that Ruby began to be known around the world. The reason for this boost in popularity was that Hansson, unsatisfied with the monotonous and redundant process required to build the application in PHP, chose to use Ruby instead. After the project was complete, Hansson realized much of the code he wrote could be made into a framework that could be used to simplify future projects. Thus, Rails was born.
I’ll admit I’m still way too green when it comes to programming in Ruby or getting the best (or anything at all) out of the great Rails framework, but I must say I’m impressed with the results I got after investing just a few hours in learning it.
I’m not a genius, it’s just that easy. With a few commands you can type into a console (or by using more intuitive drop-down style menus provided with the Eclipse based IDE Aptana), you can create the entire skeleton of a project, with all the files you will ever need, create platform independent database schemas, and even create an actual bare-bones web interface that allows you to perform simple actions on your tables (creating, retrieving, updating and deleting records)! Also amazingly is the voodoo magic (called ActiveRecord) Rails uses to know which database fields are primary keys, foreign keys, the kind of relationship, etc. Simply amazing! This bare-bones structure (called scaffold) won’t win any Web Design awards, that’s for sure, but keep in mind that getting all of this functionality requires only 5 minutes of your time and you’ll be converted.
Ruby, in itself, is an extremely flexible, object-oriented programming language. The syntax is pretty lax (and I mean really lax); you can end statements with a semicolon - or not; You can write a method’s code inside brackets - or if you don’t want to, that’s fine too. The list just goes on and on. If you’re like me, and try to get into Ruby coming from PHP, you’ll notice the differences almost immediately. Gone is PHP’s cryptic code and syntax rules. Ruby seems almost like it was built with right-brained designer types who get lost in complicated scripting languages in mind. Coupled with Rails, you can build an almost entire application from scratch and have it working in minutes, allowing you to concentrate on your design and advanced features rather than on making it “just work”.
Did I mention Rails already has AJAX functionality built-in? That’s it, I’m off to buy a wedding ring.





