Since my last post a while back on my perspective on Ruby on Rails as a PHP developer, I've been watching Rails development and the Rails community, reading the beta book, and rewriting one of my apps with Rails. As a result, I want to write a follow-up to my previous post, and talk about some things that have changed since then.
Let me spoil the ending now by saying I'd be perfectly content to not work with PHP any more and focus primarily on Ruby and Rails. That's not to say I won't continue to do PHP stuff, but given the choice, I'd much prefer RoR to PHP with any framework. Now I'll tell you why...
The short answer to the question of why is because I've been using it more. The more I've developed on top of the Rails framework, the more I've come to appreciate how it makes my life easier, helps me get done with the basic stuff faster, and, frankly, makes development more fun. For the longer answer I should probably address my own list of concerns from my previous post.
First, I've become convinced that I'd rather work on creating a site than creating a framework. I have to admit, it's fun to build the whole thing from top to bottom, but in the rewrite I'm currently doing, I'm enjoying not having to worry about what's going on below the surface if I don't want to do so. Instead, I can focus on the problem domain, the relationships, the business logic -- anything other than the plumbing. Then, if you add in all the AJAX and effects goodies that are just a few keystrokes away, you have one heck of a rapid development platform. And for someone who loves doing web development mainly because of the rapid nature of it, that's something to get excited about.
Second, as a result of having to make a quick change of hosting providers, I've gotten familiar with lighttpd, which was a great experience. Lighttpd plus FastCGI is a potent combination, and, so far, seems to be easier to work with than Apache+mod_ruby. PHP is still ahead in the area of widespread support and ease of installation, but I've climbed the install curve myself now, so I'm not as concerned about it as I was. :) IIS is still a nightmare, though.
Third, my concern about significant changes happening to Rails as the revisions roll on has been lessened as I have watched the last few releases. The 0.12 release was still a bit loose, but 0.13 has gone pretty well, and (to me at least) it seems there is more concern on the part of the core contributors to stablize and verify as much as possible before blessing a new release. Now, remember, I've only been paying close attention for the last few months, so I may be way off there, but I like what I'm seeing in that department.
So, that's it for my previous concerns, but those aren't the only reasons I'm a Rails fan. A big reason is Ruby itself. A number of people have expressed this idea of really liking Ruby after checking out Rails, and I'm right there with 'em. PHP 5 is much better than PHP 4 for those of us who are OOP fans, but PHP has nothing on Ruby when it comes to expressiveness and OOP-friendliness. Here's a quick example, which will show my newness with Ruby, so bear with me...
I was pulling datetime fields out of a database, and wanted to display them in the format "4 July 2005", but I found that strftime just didn't support what I wanted, so I just added this code to one of my requires in the lib directory:
class Time def to_s day.to_s + ' ' + strftime('%b %Y') end endThen all I had to do was display the database field, and it came out the way that I wanted. I'm sure there's a better way to do it, but that solution seemed comfortable enough to me, and it kept my view code uncluttered. It's pretty cool to be able to dig into these base (or any) objects and get what you want out of them. I heart Ruby.
Well, this post has been huge, so I'll wrap it up: I'm lovin' life on the Rails.
Comments