Dice

November 2006
Mastering Web Apps with Ruby on Rails
Ruby on Rails is an open source Web application development framework which can help build applications in days, instead of weeks or months. Is it right for you?
By Mathew Schwartz

Need a Web application development framework? Consider Ruby on Rails.

Many developers laud the combination scripting language (Ruby) and framework (Rails) as a way to quickly and easily design Web applications — and in days, instead of weeks. “Rails” succeeds, its advocates say, by allowing developers to sidestep many of the time-consuming challenges intrinsic to working with JavaScript, Active Server Pages, PHP, and even J2EE. With its Ajax integration, and numerous other bells and whistles, many developers have made Rails their new Web application development framework of choice.

Is Ruby on Rails right for your needs? To answer that question, it helps to know a bit more about Ruby, and Rails.

Ruby: Big in Japan

For starters, Ruby is a lightweight scripting language, similar to Perl, Python, and Smalltalk — familiar tools for Web application developers. “Ruby successfully combines Smalltalk’s conceptual elegance, Python’s ease of use and learning, and Perl’s pragmatism,” notes Curt Hibbs, an expert on Ruby. Yet while Ruby debuted in 1993, it never gained much of a following outside of Japan.

All that changed in July 2004 when David Heinemeier Hansson, a Danish programmer who’s now a partner at Chicago-based 37signals, released Ruby on Rails — an open source framework for building database-driven Web applications with Ruby. (The name “rails” is a play on Struts, a free open-source framework for creating Java Web applications, to which Rails is similar.) Since Rails’ release, hundreds of programmers have helped extend and improve it.

All of that work on Rails facilitates easier Web application development, plus faster development times. “Ruby on Rails is a breakthrough in lowering the barriers of entry to programming,” notes Tim O’Reilly, the founder of O’Reilly Media. “Powerful Web applications that formerly might have taken weeks or months to develop can be produced in a matter of days.”

Rails’ Smart Shortcuts

While that may sound like hyperbole, Ruby on Rails has two core principles which make it happen. The first is, “don’t repeat yourself.” Define something once, then move on. The second is “convention over configuration,” meaning Rails starts with sensible defaults, though you can change them if you like.

This combination of clarity and sensibility helps reduce development time and grunt work. For example, take the Active Record feature in Rails, which automatically maps objects to database tables, so developers don’t have to continuously code verbose database queries when building applications.

Rails also automates many processes. For example, building a Web application typically entails programming the CRUD (create, retrieve, update and delete) operations between the application and databases backing it up. Rails, however, automatically builds such capabilities into every Web application it creates.

In fact, building a basic application with Rails can be as simple as selecting a database, then running scaffold — a Rails command-line feature — to automatically generate the model, view, and controller Ruby code needed to access the database’s table. In short, using a line of code, you can quickly turn a database into a basic Web application. Of course, this won’t work with every kind of database, including many types of legacy databases. Furthermore getting more than basic information-retrieval capabilities will take some degree of programming. Rails, however, still speeds such efforts.

Ruby Heart Ajax

Yet how does Ruby on Rails play with Ajax (asynchronous JavaScript and XML)? Ajax of course, makes it easy for Web developers to build applications that don’t require a page reload every time something on the Web page changes. And really, given Ajax’s poster child — Google Maps, with its real-time, desktop-application-like capabilities — what can compete?

Turns out Rails and Ajax don’t compete at all, and actually work quite well together, thank you very much. Instead of having to choose between desktop-software-like Web interfaces (Ajax) or quickly building database-backed Web applications from scratch (Ruby on Rails), you can do both.

In particular, when building applications with Rails, developers can specify exactly which types of triggers should cause just part of a page to reload, versus when an entire page should reload. This is fundamental information for then creating an Ajax interface for the Web application.

As Rails’ creator David Heinemeier Hansson explains, this approach was intentional: “We’ve gone ahead and more or less removed the need for hand-written client-side JavaScript entirely.” Rather than developers having to battle with client-side JavaScript libraries — each browser interprets these differently, which necessitates lengthy programming workarounds — the work gets handled by the Web server.

Thus with Ruby on Rails, “it’s basically no harder to make something Ajaxed than it is not to, which means that the decision is based on whether it’s a good fit for the user interface — not on whether we have time to [create] another Ajax project,” he says.

Adding Ruby to Your Resume

Is Rails right for you? To find out, give it a quick spin — it works with most Web servers (including Apache or lighttpd, running either FastCGI, SCGI, or Mongrel) and databases (including MySQL, PostgreSQL, SQLite, Oracle, SQL Server, DB2, and Firebird). Numerous Web-hosting sites also offer Rails capabilities. Finally, Apple users will have the ability to tap Ruby for Rails natively starting in spring 2007, when Apple releases Mac OS X 10.5 (Leopard), with Rails built in.

To truly master Ruby on Rails, however, you’ll have to sit down and learn a new programming language — a time-consuming task.

That said, for developers looking to bolster their resume, “I can think of no other language I would recommend higher than Ruby,” says Richard Monson-Haefel, a senior analyst at Burton Group. In particular, he lauds Ruby’s commercial-free development, noting it’s “a delight to work with.”

To help you master the language, he suggests tapping a good Ruby book, such as “Agile Web Programming with Ruby on Rails” (Pragmatic Bookshelf) by Dave Thomas and David Heinemeier Hansson. Look for a second edition in December 2006.

Mathew Schwartz is a freelance business and technology journalist based in Cambridge, Mass.

Comments? Please contact us at feedback@dice.com.
Search Jobs

Did you know?

Many hiring companies who use Dice search our resume database before posting jobs. That means many of the best jobs are never even posted. Post your resume now, and be sure not to miss any opportunities.
Post Resume Now

More Career Insights

  • Technology Today
  • Cover Letters & Resumes
  • In The Trenches With Dice
  • Local Market Reports
  • AskDice