Ruby on Rails rocks; PHP not so much
I’ve spent the last year writing an enormous amount of PHP code for Dontbuyjunk and Turf. Before we started the project, I would have labelled myself as a server engineer. Even though I had worked on extremely large-scale web applications at my former employer, Ariba, I was on the server team and rarely dealt with any code components that were client-facing. I would have labelled myself also as an advanced Perl programmer. Perl was the only scripting language I had exposure to, so when I jumped into PHP for this project, I immediately loved it. It was leaps and bounds more convenient to code web apps with PHP over Perl. Many of the functions one would need were already there and the developer community, while not as mature as Perl, was certainly rich with depth.
Fast forward a year and my view of PHP has changed quite a bit. I still think its a very convenient way to code web apps that are very view-centric (or page-centric, whatever), such as WordPress where you have the main page, the post page, the archive page, etc. However, for building more complex web applications where there are several components, PHP just doesn’t feel well-suited for the job. Even though it is quite full-featured from a language perspective, it sometimes feels clooged together. Like, for example, the object-oriented support, which again, while being decently feature rich, it feels kind of forced when I’m writing OO code in PHP. It’s like yeah I can write decent OO code but I’m only doing it to follow my own coding convention, PHP doesn’t really give a crap and moreover other programmers working on the project will do their own thing and soon enough you start to get a mess.
This is really where Java shines. It’s a pure, from-the-ground-up object-oriented language and everything from how code is physically organized to the linking to the VM to the language itself is sensical, refined and heck even fascinating sometimes. I sometimes look back to some of the Java projects I’ve worked on, even the gigantic messy Ariba ones, and smile. For me, programming is not just about writing code sufficient to meet the task, it’s about designing elegant, efficient code that you enjoy re-reading – like a good book – can’t wait to have your peers look at. (Granted, there are plenty of times when I’m working on an insignficant task where I do just need something that works.)
I spent the past couple of days learning about and playing around with Ruby on Rails. I’m not going to go into detail about the background of RoR as there are plenty of other sites which describe it better than I can. Basically though, Ruby is an object-oriented programming language created by Yukihiro Matsumoto. One of the design philosophies of Ruby is the “principle of least surprise”:
I believe people want to express themselves when they program. They don’t want to fight with the language. Programming languages must feel natural to programmers. I tried to make people enjoy programming and concentrate on the fun and creative part of programming when they use Ruby.
Sounds good to me. And if you start poking around with Ruby I think you’ll generally agree. What really has brought Ruby into the limelight is the Rails MVC (Model-View-Controller) framework which was created by David Heinemeier Hansson (founder of 37Signals). I’ve played around with MVC frameworks, namely Struts, before and to be honest I never quite felt comfortable with them. That could also be because before when I experimented with MVC concepts, I hadn’t done much full-circle application development. Like I said, I was mainly just a server/back-end guy. But now that I’ve worked on all aspects of application development for the web, I have learned how development does sort of gravitate towards the MVC model. For Revunity, even though we never planned it, we ended up with controllers, models, and views, except that it’s somewhat of a mess. =) As I dug deeper, I was thoroughly impressed with Rails. RoR doesn’t, of course, do anything that you could not do with other languages/frameworks. But, so far, what it does seem to do is make me as a developer more efficient. Much of the tedious stuff is taken care of. I can focus on the meat of the application.

I had a couple conversations with friends about RoR and the question came up about scalability. I started to wonder the same thing and did a lot of digging. It seems like RoR apps do compare well in terms of performance with other platforms. However, I came across this post by David Hansson himself, It’s boring to scale with Ruby on Rails that re-focused my perspective on RoR. Particularly this quote:
The point is that the cost per request is plummeting, but the cost of programming is not. Thus, we have to find ways to trade efficiency in the runtime for efficiency in the “thought time” in order to make the development of applications cheaper. I believed we’ve long since entered an age where simplicity of development and maintenance is where the real value lies.
I very much agree with this. CPU cycles, storage, bandwidth, etc. are all commodities which are getting cheaper by the day. The cost of developers, and I’m talking about the passionate engineers/innovators not just dime-a-dozen coders, remains a very expensive and scarce resource. So, if RoR makes developers more efficient and happy about building applications, then it’s value is truly gargantuous.
I’m looking forward to getting involved in a project, whether for serious or for fun, where RoR will be the right tool for the job. I’m curious to see what issues (other than the obvious ones like relatively limited developer community) I will find with RoR and whether my feelings toward it will change once I have some real experience with it.

