Agile Ajax

Switching Back and Forth

You'd expect that a blog post titled 7 reasons I switched back to PHP after 2 years on Rails would generate some controversy. Derek Sivers wrote just that on O'Reilly's Ruby blog last week, summarizing his experience as follows.

I spent two years trying to make Rails do something it wasn’t meant to do, then realized my old abandoned language (PHP, in my case) would do just fine if approached with my new Rails-gained wisdom.

The post has elicited a metric oodle of comments, many of which are of the form "But don't you know PHP is ugly?" or "Thanks for finally speaking the truth about that overrated Rails stuff", neither of which is really all that helpful.

I confess my first thought on seeing the headline was disappointment, couple with the knowledge that inevitably, I'm going to suggest using Rails for a project and somebody will come back with "But didn't that CDBaby guy switch back to PHP? Doesn't that prove Rails doesn't scale to the enterprise?" Sigh.

I think, though, that there's actually less here than meets the eye. I even think that Sivers' experience is actually a good thing. Even for Rails fans.

By Sivers' account, he wanted to replace the existing, somewhat messy PHP code at CDBaby.com from scratch, in Rails. After two calendar years (which doesn't seem to have been two years of continuous work on the project), they gave up. At that point Sivers went back to PHP and coded the whole thing up in two months.

Admittedly, to a hardcore Rails advocate like myself, the story sounds a little strange, almost like giving up your automobile and discovering you can walk to the grocery store at 200 MPH.

I'd be interested to get a little more detail on what the Rails issues were -- Sivers says things like

Jeremy could not have been more amazing, twisting the deep inner guts of Rails to make it do things it was never intended to do. But at every step, it seemed our needs clashed with Rails’ preferences.

and later,

I love SQL. I dream in queries. I think in tables. I was always fighting against Rails and its migrations hiding my beloved SQL from me.

So I suspect the problem was, on some level, a clash between the existing database structure of CDBaby and Rails' expectations for database structure (and maybe, to a lesser extent, the clash between how Sivers wanted to structure the program, and how Rails did). This actually isn't surprising. Rails has very strong opinions on what databases should look like, it'd be more surprising if an existing project matched those preferences exactly.

What's a little bit more surprising is what Sivers did when he went back to PHP.

It’s the most beautiful PHP I’ve ever written, all wonderfully MVC and DRY, and and I owe it all to Rails.

He took the best parts of Rails, jettisoned the parts that didn't fit his project, and applied the principles to the code that he built. The logic is in the right place, and as a result, the line of code count is an amazing 15% or so of the original. That must have taken a fair amount of discipline to do in PHP, but it clearly worked, so good for him.

I guess I'm supposed to be upset that he walked away from my team, but actually, I'm fine with it. It's easy for me to get caught up in the particular choice of technology, especially now when Rails is in my job title. But ultimately the point is to build solid programs that bring value to the clients and users.

Rails is great, but it just isn't designed to be the One True Framework for all people. It does contain ideas and design principles that are applicable to almost any piece of software. These ideas should be implemented all over the place -- that's how all our tools get better.

I mean, it's hard to see Sivers as writing some kind of slam on Rails, when the post contains the statement:

Rails was an amazing teacher. I loved it’s “do exactly as I say” paint-by-numbers framework that taught me some great guidelines.

Or closes with this:

All that being said, I’m looking forward to using Rails some day when I start a brand new project from scratch, with Rails in mind from the beginning.

Sounds good to me.

Leave a comment

Powered by WP Hashcash

About Pathfinder

  • We design and build extraordinary applications for companies looking to make the next great idea a reality.
  • learn more

Topics

WordPress

Comments about this site: info@pathf.com