Tiger Woods and Rails
A while back, I read a post where someone was listing a few Rails performance tips. Come to find out, half of them were things like “bypass ActiveRecord” and “beware of finders” and “use HTML instead of view helpers” and so on. That’s actually a lot of why I choose to use Rails in the first place; the last thing I want to do is rid myself of convenient ways to avoid tedious programming. If you want to write explicit SQL statements or standard HTML, maybe Rails isn’t the right framework. I’m pretty sure any of the Microsoft options don’t have a problem with explicit SQL, but beware, .NET does like to make up it’s own HTML at times.
I don’t have much experience with other web frameworks (except .NET… blah). I was just about to try out Cake for PHP when I was introduced to Rails. Having said that, Rails is what I know best. I think Rails sometimes catches some flack for things because it does so much already, it’s expected to do more—somewhat similar to Tiger Woods.
Let me explain. Tiger Woods is legitimately said to be the world’s greatest golfer. He has set a number of records, and truly is amazing to watch. But what happens when the world’s greatest golfer gets a bogey? Or heaven forbid, a double bogey? Extreme shock, disappointment, and disgust. That’s hardly a fair attitude considering all that he has accomplished. Since he’s currently the best, the expectations of him have far surpassed those of any other golfer—it’s almost surreal.
Rails’ expectations are as high as they are because of how astonished people were in the beginning. It was so easy to work with, but at the same time, everything is relative. It was so easy relative to writing an extra 20 lines of tedious, unnecessary code. Convention over configuration allowed stuff to just “happen.” Now, it’s like Rails gets compared to itself, and it’s supposed to go above and beyond that, which is an endless cycle. I guess it goes back to the old proverb, “the more you get, the more you want.” But don’t forget how painful things used to be, and appreciate how things are, today. After all, it can only get better.
I personally blame Rails to be the culprit for my web programming passion (and yes, it’s Ruby’s fault, too). I don’t know if I would love this stuff near as much if I were stuck in a static environment where my own customizations and ideas couldn’t be put to work. While I rarely do this, I love having the option to dive right into the framework itself and change/add things specific to my needs. Not to mention the sheer beauty of its organization, configuration, and presentation. And being built on top of Ruby makes it that much better. Clean code gives any mindful programmer motivation; and with (Ruby on) Rails, I’ve written some of the cleanest code of my life. Rails is much more than I could ever expect from a framework.
If you’re upset with Tiger Woods not shooting 20 under, or having a “par” day, simply don’t watch him. But I bet you won’t get near the excitement watching someone else.

Nick Tuesday, 03 Apr, 2007 Posted at 10:50AM
I like this post. I read somewhere the other day that ActiveRecord is only 50% slower than “going right to the metal”... 50%?
Chris Tuesday, 03 Apr, 2007 Posted at 12:26PM
ActiveRecord is, in my opinion, the greatest piece of the Rails MVC pie. Why? Because I don’t have to worry about my SQL statements. Abstraction always adds overhead, but (as you’ve already said) it’s the abstractions that make the framework so useful.
Ryan Tuesday, 03 Apr, 2007 Posted at 12:27PM
Only 50%? Come on, what’s the difference between 5 seconds and 10 seconds? That’s hardly worth worrying about—LOL. I’m not doubting you at all, but I’d be surprised if what you read was true. Besides, even if it is true, in general SQL is pretty quick. I just logged into MySQL via the command line and ran a query on one of my tables containing 276 records to see how long it took. SELECTing all of them took 0.09 seconds.
Of course, this is just my opinion, but doing this…
...over this…
...isn’t worth it to me. Who knows if that example is right, but you get the idea. If I’m only going from 0.18 seconds using ActiveRecord (assuming it is only 50% as fast) to 0.09 seconds with direct SQL, I’m willing to sacrifice those 0.09 seconds. Plus, throwing variables directly into a SQL statement isn’t good practice.
But obviously, it’s totally up to the individual and what they need. If I had 1 million people hitting my database, I might take that 0.09 seconds more seriously. For now, I’m personally going to continue to enjoy the niceties of ActiveRecord, and the other things that make Rails what it is.
Ryan Tuesday, 03 Apr, 2007 Posted at 12:58PM
Apparently I was using the wrong comment body for the feed, because the code samples were all jumbled together. Anyway, I just fixed that, so if you get 200+ new comments for rpheath.com through your reader, sorry about that :-)
Chris Tuesday, 03 Apr, 2007 Posted at 01:19PM
Performance isn’t an issue until it’s a problem. Oh, and when you get a million visits/day… well, I just don’t see it happening :-p You probably have tiny beat exponentially, though hehe.
Ryan Tuesday, 03 Apr, 2007 Posted at 02:44PM
Ha, when I said “For now…” it does kind of imply “Until then…” but that is not AT ALL what I meant. It won’t happen and I don’t want it to. There was a time when I used to actually care about visits and stuff, now it’s more-or-less an interest in data I guess. To be honest, I don’t even know why I have this site anymore—sometimes I just get so tired of it.
As for tiny, I’m probably your #1 visitor. I feel like I’m always digging through your site looking for some tip or trick about Rails. In those moments, I long for a search, but scrolling usually let’s me to find more than one needed reference :-)
Chris Tuesday, 03 Apr, 2007 Posted at 04:22PM
Honestly, I find myself digging though tiny finding stuff as well. And I do have a search by the way :-p It works really well, actually… except that it also tracks my ‘Edit’ links since they are exposed on the main site.
Ryan Tuesday, 03 Apr, 2007 Posted at 05:46PM
Ahh… what, did you come up with that in your garage or something? I went ahead and bookmarked it, so I don’t have to type site:tiny.scharfie.com every time—I’m so lazy. Anyway, that should help. Thanks, I hadn’t thought of that.
Chris Tuesday, 03 Apr, 2007 Posted at 05:59PM
You could take it a step further and add a quick search to Firefox. Just add a bookmark to
http://www.google.com/search?as_sitesearch=tiny.scharfie.com&as_q=%sand give it the keyword “tiny” – now you can dotiny ruby-fuin your address bar :-)Ryan Tuesday, 03 Apr, 2007 Posted at 07:53PM
Sweet.