Why rails?

June 11th, 2008

Why Rails?

Ruby on Rails is a tool for making web applications—and it’s freakishly good at it. If you’re reading this (which, evidently, you are), you’re probably wondering what makes Rails so special. When you ask this of a programmer who has already fallen in love with Rails, maybe he’ll tell you it’s “agile,” and you’ll have to read up on what that means to coders. Or maybe you’ll be bombarded by a list of acronyms like ORM, MVC, or DRY. While these are all cool features of Ruby on Rails, the real reason Rails rocks is not about vocabulary; it’s about the philosophy of efficient design. There’s that word: design. It’s a slippery concept, yet unmistakable. Good design is like pornography: You know it when you see it. Rails is like very, very good pornography. What makes the design of Rails so good is difficult to pin down, but we’ll do our best. We think the heart of it is free productivity.

Productivity wants to be free

The essence of free productivity is the eerie ability Rails has to anticipate your needs as a web programmer. That’s not very concrete, though, so let’s get a flavor for the free productivity Rails provides by looking at a list of examples. Not all of these will make sense to you right now, but they should help you develop an intuition for the kinds of things Rails is good at.

• Ruby:

Rails applications, as well as Rails itself, are written in Ruby, a dynamic, object-oriented programming language. Ruby comes out of the Perl tradition, and Yukihiro “Matz” Matsumoto, the creator of Ruby, calls it “a better Perl than Perl.” In our experience, most programmers with exposure to both languages agree. We’d add that, for web programming, embedded Ruby (ERb) is a better PHP than PHP. Being able to tap into the power and elegance of Ruby is a major advantage of Rails.

• Mapping of database tables to Ruby objects:

There are no messy SQL1 calls in most Rails applications—instead you’ll find Ruby objects and methods. Rails does the dirty database work behind the scenes. (If, by some chance, you do want to execute some raw SQL, Rails lets you do that, too.)

• Automatic conversion of data models into HTML and back:

There is seamless integration between the code for modeling objects in your system and the code to display them to the user. This is nowhere clearer than in data validations; for example, if your data model requires users to put in an email address, but the user submits a form without one, Rails can automatically catch the error and put it in a variable for display back to the user. Built-in support for automated testing of data models and web pages: Rails makes it easy to write test suites that verify the integrity of your data model and the correctness of the pages on your site, allowing you to be confident that changes to your code will not break your application.

• Database-independent creation and alteration of database tables:

Rails migrations make it easy to create your data models, make changes to them, and roll them back if necessary, all in a way that makes it possible to use the same model for different databases.

This writing is word for word from RailsSpace. Thank you!

Leave a Reply