Wednesday, June 28, 2006

Ruby on Rails

I got hold of this stone when I attended a presentation organized in the geeknight at ThoughtWorks. The presenters (ThoughtWorkers) were highly enthuisiastic about this project that they had just developmed using the Rails framework. I had only vaguely heard about this new opensource framework and had put it aside as another addition to the slurry of web frameworks that are already in use. The claim that it achieves ten times faster development appeared fantastic - a conclusion drawn from one-off occurence! It was only when I attended this presentation that I got to appreciate the beauty of this precious framework (read stone :)) and how it gets near zero turnaround time.

So what is Ruby and what is Rails? And what then is Ruby on Rails!

Ruby is a dynamically typed object oriented programming language inspired by other languages like Perl and Smalltalk. And Rails is an open source web framework developed in Ruby. Within a short period, it has gained in popularity for its reduced development time and higher productivity. It is known to be one of the most well thought-out frameworks in existence today.

Rails’ support for agile web development can be attributed to various features and its guiding principles - Do not Repeat Yourself (DRY) and Convention over Configuration. Database backed enterprise applications developed today have quite a few things in common. A UI component, a controller component a model component, and an ORM layer. Frameworks like Struts, Spring while providing these components, leave the configuration part to the developers. The developers have to do the menial task of building the configurations and the bunch of XMLs that are common in any application. This leads to a copy paste mentality and repeatative code across applications. It is precisely this that Rails tries to eliminate.

Ruby by its very design makes it easy to create domain-specific languages and metaprograms leaving the developers to just focus on the business logic. Also, Rails has its self defined convention for integrating the various components that form part of this full stack framework (ohh yes, its a full stack framework so no need to manage the idiosyncracies of different frameworks at different layers). Thus no more XML configuration files! Talking of the full stack support, Rails has various components that map to the M, V and C. Active Record maps to the model. The programmer is only required to subclass the ActiveRecord: : Base class; and the program by itself determines the table and column details! View is implemented by Embedded Ruby with syntax close to JSP. Controller is taken care of by the Action Pack classes.

What more but new technologies like Ajax and Web Services have been integrated with Rails making it convenient to implement applications requiring their use. Among its other features, good programming practices forming a part of this framework result into easily maintainable code.

All this might sound like I am painting a rosy picture but try it out now... get your hands dirty and you will see that they don't get all that dirty after all :-). Of course RoR can't be without its drawbacks; nevertheless its promising features were convincing enough for me to choose it as the topic of my final year MS dissertation!

Pointers-
http://www.rubyonrails.org/
http://wiki.rubyonrails.com/rails

-Ashish.