Web development frameworks – part 3 : Ruby on Rails
Unless you have been living under a bucket without an RJ45 port (yes, some buckets have Internet access), you have probably heard of Ruby on Rails (RoR), it’s a very popular framework with lots of momentum. RoR started as an extract of the Basecamp product at 37signals and is now used in all sorts of web apps.
I used RoR 3.2 on a Fedora 16 based workstation for this review. All the base documentation was taken from the official RoR site. Anyway, let’s get on with it.
Install the framework in a development workstation
Two basic steps and you are good to go:
- Install ruby and rubygems (using yum, apt-get or just download them from the RoR site)
- Install rails using gems (# gem install rails)
On a sidenote, I had to install a few dependencies I was missing (ie. sqlite-devel) that were not tagged as dependencies for either ruby or rubygem, but without them the rails command fails.
Setup a development environment using a free IDE, application server and database
You don’t really need much more than a good text editor for RoR, I’m using the Sublime Text 2 editor (which is very nice to use and has nicel Ruby coloring/autocomplete).
Develop the “Hello world” or similar sample outlined by the frameworks tutorial
To create my “Hello world” I followed the official getting started guide. I had a few minor issues getting my first app working, probably because of the noob component.
Going from the “vanilla” project to a “Hello RoR!” status was quite easy, just one command line to generate my first controller and view, edit the view file and set the new default route in the routes.rb file.
Note that there is an error in the tutorial if you use the latest Rails version, when you add the tags support to the Post model you need to add the :tags_attribute variable to the attr_accesible line or you will get a security error (apparently this was optional before, but now it’s mandatory).
Modify the sample app to perform a specific database query over a custom structure and display the results
Active Record, the default ORM library provided by Rails is quite powerful and easy to use. You can perform all the stuff you would expect using the provided Ruby API, and you can resort to your custom SQL commands if you want/need to.
Adding a custom SQL query to the tutorial sample was really easy, even more if the result maps to an already existing model entity.
Add a dependency to a third party library and perform a computation using it in our app
Using RugyGems as the backbone of the dependency management makes using third party libraries in Rails quite simple. The community is huge and very active, just out of curiosity I did a $ gem query –remote | wc -l and got almost 39.000 items listed.
Develop a “Hello world” REST service
The REST concept is core to Rails, so you don’t really need to do anything special to support the HTTP verbs. Formatting your output as JSON is also a built-in feature of the framework.
Anyway, developing a new REST based web service is just a matter of minutes.
Consume our own service from our app
You can use Active Resource to map RESTful resources to Rails models and then use them as any other model, it’s really cool :)
There are also other options, like straight HTTP fetching using the facilities Ruby provides or some specific gems like HTTParty.
Learning curve: GOOD
Learning RoR falls definetively on the easy side, if you already know Ruby and have a working knowledge of web development it’s a piece of cake. In my case, I had no clue about Ruby but found it similar enough to other languages I have worked with, so I felt right at home in a few hours.
Development performance for simple tasks: GOOD
If you consider all the work the generators do for you, add the thousands of Gems already available and finish it off with the really heavy use of convention over configuration that the framework promotes, you will agree that developing normal stuff is fast, and I mean Speedy Gonzales fast.
Development performance for complex/singular tasks: GOOD
Rails provides some help by not getting too much in the way when you want to develop something the framework doesn’t really foresees. So it basically falls to Ruby itself, and I found it complete enough to say you will probably manage to solve your business/domain specific problems with the same level of complexity and frustration you would find in most other broadly used languages/frameworks.
Dependency management: MEDIUM
The Gems and plugins support is good enough, it provides the things you need to keep your project under control and use external libraries. It does not provide all the features and customization tools like Maven do, but it probably fits most projects needs.
Code performance/security tuning capabilities: MEDIUM
I probably lack enough experience to pass judgment on this point, from my initial review and the apps I coded it seems RoR does a lot for you but it’s not that easy to get into it’s guts to fine tune it for security and performance, specially for mission critical and/or enterprise class applications. But I will probably review this statement after I deploy a few RoR apps myself in the real world with a considerable load.
Platform escalation/redundancy capabilities: MEDIUM
I will get a few insults for this, but being a scripted language that doesn’t run inside a controlled memory managed VM makes Ruby and therefore Rails an inferior contender for really big deployments compared to Java or .NET. I’m not saying you can’t deploy big RoR apps that serve thousands of users, I know there are real world examples of this, I just think that for the average IT crew it’s easier to control the scalation of a Java based app than a Rails one.
Acceptance in corporate markets: BAD
This is pure perception, but at least amongst my company’s customers Ruby isn’t even on the map. You tell them the next software you will provide will run under Ruby and the best thing you can expect to hear is “Whaaaat?”.
Complexity of developing and consuming SOAP and REST services: GOOD
Developing and consuming REST services under RoR is a piece of cake. Using SOAP requires a few more steps but it’s easy enough too.
Ruby on Rails v3 is easy to learn and use, provides amazing development speed of web based applications and has a large and active community behind it that will help anyone making his first steps solve most problems.
From our evaluation perspective the main drawback of RoR is the lack of acceptance in the corporate sector, even though Ruby and RoR are now known by most people in the web development world, they are not yet accepted as serious platforms for mission critical solutions in sectors like banking, telecommunications, and the like (at least on the south half of the world :)).
So if your boss is OK with it, or if you are developing an independant solution, I think RoR is an amazing option. And as time passes and more people use it, I’m sure it will become a serious contender for Java and .NET.
Reference: Web development frameworks – part 3 : Ruby on Rails from our JCG partner Ricardo Zuasti at the Ricardo Zuasti’s blog blog.