home icon contact icon rss icon

How I Learned to Stop Worrying and Love Rails

If I don’t get a ton of flack for advocating Rails in a new corporate environment, I immediately know something’s wrong.

Ok, so I’ve only been in two situations where I’ve dumped an application off from being PHP/Java and ported it to Rails. But both times, I didn’t do it because I was bored, or because it was the cool thing to do. I did it because the current codebase, a puzzle box that only the original developer can easily crack open, was almost impossible to work with.

A lot of people (most whom haven’t ever seriously used the framework) loathe Rails because it’s opinionated. The framework believes that things should be done a certain way, and this usually (although now not as much) came from the core committers who dwell in the aether regions, who have undoubtedly learned through experience that best practices really do exist. And these same people feel that Rails is too restrictive, and when you let them know that you can, for example, have an ActiveRecord model link to another table than the expected one, you’re likely to hear more attempts at pointing out the Failures of Rails: but it can’t scale! it’s slow! no serious company uses it! Yeah, it won’t scale when you script/server up Webrick and think you’re ready to go. Is it slow? Sure, if you’re creating a Ruby protein folding application…if a web application is sluggish, most likely the clog is due to poor design or a less than ideal server environment (in my experience, database servers usually die faster than frontends). Plenty of companies use Rails, and more come onboard every day, but because it’s a young framework, the older (and hence, more ‘serious’ companies) aren’t ready to ditch their current codebase to start anew.

Before this becomes a Ruby on Rails lovefest, let’s get back to the title of this entry. Why don’t I choke in the restrictive confines of the Rails framework? How come I haven’t run back to the safe arms of PHP, yearning for a life of more control?

Ruby is an amazingly dynamic language. Anything is possible. Blocks, closures, meta-programming, et. al. make for a genuinely rare programming experience. Because Rails is built off Ruby, one doesn’t need to feel trapped by a framework that attempts to make life easier by taking common expectations and leaving you free to decorate the carriage, rather than reinventing its wheels. There is a thing we Ruby developers love to do, and this thing is monkey patching. Anyone who’s realized the power of alias_method_chain and how to weave in and out of classes and modules, reworking the framework to fit your every need and desire, knows how liberating making Rails her own can be.

Because developing in Rails allows me to leverage Ruby in refactoring and patching the framework for my project’s concerns, I have more time to do other things. Like thinking. Not to sound like an elitist who, like Aristophane’s Socrates, walks amongst the clouds (ha!), but I’ve learned that developers who spend most of their time thinking about their project, rather than grueling over mundane tasks and busy work, do better. Their projects are stronger, easier to build upon, and organized well. These developers spend much of their free time doing things like evangelizing the MVC paradigm, reading non-fiction, and dining out. Their counterparts - those who fear the surge of extra web traffic, faulty error handling, and accidently falling into while() loops that never end - live in fear of their creation, dreading the day when their creation will turn on the parent. These developers spent too much of their time drudging in the mud, toiling and hammering away inconsistencies and blemishes - had they not had these concerns, perhaps they could have tackled their infinite loop before it got to them.

DISCLAIMER: The point of this article isn’t to attempt to prove that Ruby > PHP (though for me and my style, it is.) It’s aimed at those rugged individualists who believe that frameworks are for sissies and code should be slung about. Unfortunately, when it comes to the reality, these developers are jacks of all trades, and masters of none. And because they’re masters of none, and usually aren’t experts at every facet of a full fledged application, their work is full of holes and prone to disaster. My advice? Decorate the carriage. Let the wheelwrights, blacksmiths, and other masters of their trades dictate and develop the base functionality of your applications. It’s the mark of a hobbyist to develop everything from scratch; a master leverages other people’s ideas and expertise. If you’re being paid to make a product, or your application is mission critical, be the master!

So stop worrying about suffocating within the Rails framework, and realize you’ve been lied about the flexibility of Ruby on Rails - start thinking about the amount of time you’ll have to seriously consider what you’re working on, rather than rushing to meet deadlines and squashing bugs.

Unixmonkey said

Feb 19, 2008 @ 06:04 PM

You said exactly what I've been holding on the tip of my tongue for months now. Rails has its own learning curve, and a surprising amount of app design will still require you to know how things work on the low level like forms interaction and database design, but once you've soaked it all in, you can start spending your time thinking about how your app should function and prototyping new features. The expressive nature of ruby and the splitting up your app into small MVC chunks can really cut down on the line noise when writing and reviewing code. I shouldn't have to reinvent cookies, routes, sessions, the flash and manually tie together table relationships every time I start a project. Hell, even if you don't use Ruby or Rails, use some kind of framework that keeps you from repeating yourself in little chunks of code all over the place. Don't let the "not invented here" mentality force you to write a bunch of code that is already available as a plugin or module. Chances are, its built better than you could do it, and if not, then contribute back a little and make the web a happier place overall.

Nick said

Feb 19, 2008 @ 08:19 PM

You have no idea how refreshing it was to read this. Here's why: I'm a brand spanking new developer, and months ago I decided that Ruby and Rails was going to be my first language. Then...week after week, I began reading post after post, comment after comment, of people bashing rails and sayings "Don't believe the hype" or others saying "Its the future! Proceed!". To put it plainly.. I got scared and backed off waiting for the waters to calm. This is a big step for me.. my first language so I WANT to believe im making the right choice. Your post put things in perspective a bunch, so I'll proceed with confidence, ignore the naysayers, and BELIEVE that Im partaking in a language that just may be the future for web apps. Hopefully I'm right. Thanks. I'll be checking back often.

Vitor Pellegrino said

Feb 19, 2008 @ 08:32 PM

Great post. I totally agree with you at your points. Keep the good work.

Glenn West said

Feb 20, 2008 @ 02:57 AM

Great post. It pretty well sums it up. Been doing rails last 6 months, got two apps running production, and doing a enterprise migration now with 400+ tables. Its better than any of the other languages, for industrial heavy lifting

Green Rails said

Apr 13, 2008 @ 03:51 PM

Very nice post. Having been around the block a few times, I find the current state of Rails' discussions remarkably similar to many of the giants upon which it stands. But different in a critical way. Java was the embodiment of coolness when it came out. Hot, hot, hot. Then people realized it was not perfect and it spent several years getting a little more mature while people bashed it relentlessly. After a while, it was accepted as a very good language. Java is failing, however, because it is now burdened with what seemed to be noble objectives by its creators, specifically J2EE. J2EE was huge and tried to be everything to everybody, and made a perfectly good language anything but a productivity tool. Half baked alternatives emerged, but the damage was already done. The Rails community today is very different. The goals seem almost opposite of Sun's very corporate take. Almost anyone can put forth their opinion (ok, anyone can, as these words I type demonstrate) and opinions abound. But what is really amazing is that the new alternatives are springing up faster and more furiously than they did with Java. New variants of Ruby (Sapphire), new frameworks (mERB), and even new source control tools (git) are creating a great deal of noise and distraction. Do we really need to replace SVN? (I lived with CVS for a long time, my expectations are low indeed :-). The problem? First, Rails is a fine framework, for the reasons you state. Not perfect by any means, but most of its limitations result from lack of maturity. But maturity comes from use and refinement; if everyone is spending their time switching to the next best thing (every 3 to 6 months) we'll live in a constant state of immaturity. Second, when there is so much sound and fury about what's right or wrong, none of the alternatives will "win" either, and well be back to Java, PHP and others. There will be little demand for Rails so no one will get paid to do it. Where Java had a company behind it, and not any other really compelling alternatives (.NET is a complete wannabe), Rails is in a more volatile world. Rails seems to be suffering the same fate as Unix, which was demonstrably superior to other options, yet never given the completeness that made is reasonably accessible to normal humans. Which of 5 (or 35 flavors) should I use? Even Linux has multiple distros, which helps me how? OSX and Ubuntu, now 35 years after Unix was created, might have a reasonable pass at bringing Unix to mainstream. But it will take a lot more years to undo the damage of DOS and Windows. The question is whether there is any reason to think the volatility will settle this time. I hope so. Tom

RSS feed for comments on this post

Leave a Comment