Categories Open SourceProgramming

Ruby on Rails : First look

Yes, the hype got me! I don’t know if you noticed it, but lately everyone seems to be talking about Ruby on Rails. No matter what web stone you peek up, you find Ruby-on-Rails under it. Until now the only thing I knew about Ruby was that it is a language closely related to Python. It follows some of the basic rules Python does. I (as you might already know) happen to like these rules!

Now Rails is a web application framework written in Ruby. Until know we’ve seen many web application frameworks, but I don’t remember anyone being so hyped! The main web site of Ruby on Rails, advertises the thing with motos like “Don’t Repeat Yourself”, “Convention Over Configuration”, “minimum code”, and much more. It really excites your imagination, on what this revolutionary thing can be! So I just dived in in order to find out what is the thing that makes everybody talk about it. Specially from the point of view of : Why don’t we have such a thing for Python.

I must say I was impressed. Not so much because of the technological accomplishment, but from the “carry out” of the project. Ruby-on-Rails is a complete system to develop web applications from start to end, that follows the rule “Make simple, simple. Make complex, doable”, and is focused on being used by other people! There is a big effort in that direction behind it. Tutorials and video tutorials are available to catch the eye of a possible developer. You can’t stay unaffected when you can create a web application with forms to update and view data in a database in 10mins, with almost no code!

Rails gets its power from the dynamic capabilities of Ruby. This is one of the things that excites me with dynamic languages like Ruby and Python. You can actually write code that as I say it “is aware of itself”! With Ruby (and with Python) you can create a class that inspects a database table and create a class that contains methods to access that specific table. Things like meta-classes and reflection are used in Rails, and really makes it possible to create simple applications without having to write a single line of code. Rails examines the database, the available HTML templates, etc and tries to do the right thing dynamically. For example if you create a class named “Customers” to use to get data from a table “customers” in the database, you don’t have to write code. Rails will “guess” that with a class named “Customers” you will probably try to access the table “customers” and will populate the class with methods to do so! I know this might look a bit scary to some, but this is the default behavior. You can manually change anything you like. In a similar manner the method to edit a customer will generate the correct HTML forms to do so automaticaly and then you can come in an change what you don’t like.

An other powerful point of Ruby-on-Rails is Ajax-on-Rails. This allows to write AJAX enabled web applications without writing Javascript, that can be a big pain with all the browsers available.

But what I really think is the big win in Rails is that it stricts the programmer to use a specific programming model. It doesn’t allow you to do whatever you want even with the directory structure, you have to follow rules. This helps both beginners what would otherwise have no clue on how to organize things, but also advanced developers can benefit from this since you will be able to jump in an already started project and start working on it easier.

The feeling that Ruby-on-Rails left be with is jealousy. I would really like to have a similar framework for Python. There is nothing in Ruby that Python can’t do, so it is a shame not to have a similar framework. The good thing is that there is an effort to create something like Rails for Python. For example Subway. It is still in the beginning but there is nothing to stop it from being Rails for Python.

Python, Ruby, Rails, Web framework

About the author