»
S
I
D
E
B
A
R
«
My X is better than your Y – PHP/Ruby Edition, Part XVI
July 12th, 2009 by Bill

This post started as a comment to a recent post on KillerPHP.com entitled, “What happened to Ruby? And why PHP is KING of the Web.” The longer my comment became the more I thought I could use a little Google juice myself and why let someone else have all the fun?!

A Twitter post by the normally well-reasoned Cal Evans, Director of the PHP Center for Expertise for Ibuildings lead to my discovery of the KillerPHP.com post that seems to be only the latest in a long line of PHP versus Ruby/Rails rants. I can’t imagine Cal is trolling near as much as it appears the post’s author, Stefan Mischook, but I digress…

I have been a PHP developer since 2001 and founded OINK-PUG in 2005, a month before I discovered Rails and came to enjoy writing Ruby. I prefer Ruby but cannot escape PHP because there is just so much PHP work out there! I am active in both communities locally and would be remiss not to send a shout out to the folks at CART and CincyRB too.

It has been my experience that there is a vast difference in the two communities of developers. Due to PHP’s popularity and low barrier of entry, many developers find it very inviting, especially those with little or no experience. Without much intellectual investment you can produce some rather impressive results, especially using products like Drupal and Wordpress.

Where Ruby shines is when the job calls for something that falls outside of PHP’s sweet spot. Personally, I think it does an equally good job in PHP’s sweet spot but that’s another post. These more challenging cases require more than parochial knowledge of software development; even seemingly simple concepts like a Web UI for SMS can benefit from the skills of a craftsman. That’s where the Ruby community shines and the PHP community falls a bit short.

I suggest that the primary indicator of this is the Ruby community’s embrace of test driven development (TDD) and its relative absence from the PHP community. I would ask those readers who have inherited someone else’s code for both PHP and Ruby projects which they’ve found more maintainable, PHP or Ruby? I always swallow hard when looking at someone else’s PHP code for the first time whereas I know in a minute whether or not a Ruby/Rails project I’ve inherited is going to be trouble. I just look in the “test” directory in the project’s root directory or run rake, created by fellow Cincinnati Rubyist, Jim Weirich by the way!

TDD is only one example of what differentiates the two communities. I can’t count the number of PHP projects I have inherited that were clearly devoid of source control management, or even simple code convention. Excluding the never ending “Spaces vs. Tabs” debate, I’ve never encountered either of these problems with “legacy” Ruby/Rails code. I invite everyone with more than a couple years experience IN BOTH LANGUAGES to add their thoughts about my claims in the comments below. Everyone else, knock yourselves out. Beat me up. Beat on Stephan. You won’t, nor should you expect to change either of our opinions.

Yes, Twitter could have been written in PHP, Wordpress could have been written in Ruby, and Drupal in Python. If that’s all you’ve taken from this post then you’re not “getting it” or more likely, I’ve poorly stated my argument. Nonetheless, clearly Mischook has a bone to pick with Ruby but I find nothing new in his rant and took the bait anyway. I’m overjoyed that he loves PHP so much. I did too, until I found something that “I” like better. I don’t feel the need to justify my decision to others, although I think I just did. Anyone (including me) can write bad Ruby code. Some can write beautiful PHP. In fact, some of the brightest people I know still write PHP but I say, let them eat CakePHP.


  • joebob97213
    The recently released NetBeans 6.7 added support for PHPunit. This provides code coverage similar to Junit, Ruby and Python. I'll have to upgrade and give it a try.
    http://www.netbeans.org/kb/docs/php/phpunit.html

    -Frank
  • elizabethn
    Hey Bill,
    Nice post :)

    I wanted to quickly comment on the TDD. I think Sebastian has made real strides in extolling the virtues of testing, especially with all his great work with PHPUnit. As well, PHP held a month of testing with a "testfest" in May (and improvements in testing tools like SimpleTest are making it easier for everybody), and if you ask any truly professional PHP developer if he/she tests the code, the answer will likely be "yes!" So I think it's getting better as time progresses and the TDD advocates continue to educate the masses. The mindset may not be completely there yet, but like you said, the reason is PHP's pragmatic nature and the low barrier to entry. Of course this has been said before, but PHP's strengths are also it's weaknesses - you make something easy to learn and use, and everybody will easily learn and use it... traditional programmers and hobbyists alike. Such is the case with version control, I think. Its importance and application is gradually seeping down through the ranks, but honestly, when you're the only web developer there (doing design, development, sysadmin, everything)... version control may just seem like a big pita. Of course, it only serves to help yourself, but some likely still need convincing. :)

    As far as the "tabs versus spaces" debate goes, that's just another example of a PHP strength/weakness - its flexibility. There are 1000 ways to get something done in PHP, which means that every programmer will do it his/her own way (which is also likely not the same way as everyone else). But personally, I love that freedom and that control. I love being able to decide what *I* think the best way is to get from Point A to Point B. This is also why, despite popular opinion, I love the fact that there are 47 million PHP frameworks. You can choose to use whichever one you want. Or none at all. Or write your own (which is what many people end up doing.) A lot of people see this as another reason PHP shouldn't be taken seriously, but I love the freedom of choice. (Which is also why I think commenting your code is crucial, especially in a PHP script - you have to give insight to future maintainers not only what you're doing, but why you chose to do things that way... but that's another story for another time.)

    I won't bash Ruby or Rails, or Python, or Perl, or Erlang (mostly because I don't understand it), or other languages that are helping someone somewhere accomplish what they need to get done. I think that's like saying "my car is better than your car," when all a car really does is get you to your destination.
blog comments powered by Disqus
»  Substance: WordPress   »  Style: Ahren Ahimsa