Ruby, PHP, and Frameworks
I began my computer consulting career in 1999 as a PHP programmer. For several years, all of the Web sites I created were written in PHP. (I have done a couple of ASP.NET sites, and although I find the technology and the development tools to be impressive, the requirements that you develop and run ASP.NET on Windows is a non-starter for me.) In 2005, while at the Apple Worldwide Developer Conference, I first played with the Ruby on Rails framework, released a couple of months earlier. So, like many people, I came to Ruby after seeing how brilliant the Rails framework was. At that time, there really were no PHP frameworks that were comparable, although perhaps the Zend Framework, among others, are close enough today. I wanted to talk a bit about how I see PHP and Ruby, but first, a discussion of frameworks…
Some people have asked if Ruby on Rails really is better than PHP. This isn’t an appropriate question, however. PHP is a programming language that can be used for many purposes, by far the most common of which is development of dynamic Web sites. (PHP can be used for other purposes, including creating command-line utilities or even graphical applications; it’s just not used for those purposes nearly as often.) Ruby is also a programming language that can be used for many purposes, perhaps most commonly for command-line and system utilities. In part thanks to eRuby (Embedded Ruby), Ruby can also be used for Web sites. Conversely, Ruby on Rails is a framework written in Ruby. A framework is simply a library of existing code that can be used to facilitate application development. Ruby on Rails is Ruby’s most popular Web development framework, although not the only one. For PHP, popular frameworks include PEAR and PECL (depending upon how you define “framework”), Symphony, Cake, and Zend. So any comparisons to be made aren’t between PHP and Rails but rather PHP and Ruby or the Zend Framework and Ruby on Rails. Over time I’m going to make this second comparison myself and post the results here.
As for PHP versus Ruby, I’ll say that subjectively, PHP is my first love and is still the language I turn to for updating existing Web sites (rather than rewrite them in Ruby) and for creating simple Web pages. I think PHP is really easy to learn and use, especially for those purposes, and both writing in it and debugging it is rather easy.
Ruby is kind of amazing. It’s a pretty impressive language with lots of great features. As an object-oriented language, PHP can’t really compare. The ability to alter existing classes–even those built into Ruby, like String or Array–on the fly is fantastic. And I find installing and using RubyGems to be easier than PHP’s PEAR or PECL. When I’m working with PHP, one thing I miss is Ruby’s irb, the command-line Ruby interpreter that can be used to test small bits of code.
I’ll add some more specifics in future postings but I wanted to put this basic info out there immediately. I will also say that I put little faith in discussions of security or performance when making comparisons. A bad programmer can make really insecure applications using a very secure technology so I think that saying any language or technology is more or less secure is inappropriate. As for performance, there are so many variables there that, again, just saying X is faster than Y is not often meaningful. One of the argument’s for using Ruby is that it’s very quick for you, the developer, to use, and your time is far more critical than the computer’s.

Hi Larry,
Have not heard from you for some time. I knew you will run a blog some day, and today proved it. Coincidentally, I have been developing a website using Ruby but have stopped for a little while now as I am rushing some of my school work. It is definitely nice to use, like you said; the argument is that people are generally saying that its speed is faster. Being not a pioneer in both PHP nor Ruby, I dare not say so. Your blog is really nice and simple and (coincidentally also I have been building up a blog, in fact just now). You have been a great source of teacher in my opinion, do keep up your strong interests in programming and keep me informed, Thank you.
George.
Comment by George — December 4, 2008 @ 5:16 am
Hello, George. Good to hear from you and thanks for the feedback. Hope you’re doing well!
Comment by Larry — December 6, 2008 @ 1:36 pm
Hello Larry
Good to see you blogging I have started recently myself. I am a fairly new reader of your work and would like to thank you for your contribution and to making all this very attainable for a late starter as myself (I’m 36, not usually an age you hear when asking a programmer when he started coding).
Anyway I noticed you referring to Ruby On Rails and was interested to know your opinion of Python and Django in general. Being a new programmer I’m wondering if the PHP MYSQL route is a reasonable starting point for my Web Development project I’m doing for my employer (I have your PHP MYSQL third edition book but haven’t read very far yet)
Thanks Larry
Comment by Joe — December 7, 2008 @ 12:40 am
Hello, Joe. Thanks for your comments and the nice words. Don’t worry about being a late starter, I hear from people reading my books at 13 to those picking them up for the first time at 60! In answer to your questions, I don’t have any personal experience with Python and Django so I couldn’t say. Maybe I’ll add that to my list of things to look into. But I do think PHP and MySQL are great technologies to use for Web development and they are particularly good for those new to programming and Web development in general. PHP is hands-down a very accessible language! Thanks again, Larry
Comment by Larry — December 7, 2008 @ 1:04 am
Thanks again Larry for taking the time to clarify this topic.
For programmers just starting out, it’s always tricky to decide where to start and what to start with. It’s easy to be put off by the difficulty of programming if you happen to delve into the world of, say, Java as a starter. It is a massive language, and although it can be used to create powerful web applications as well as other types of apps, I can imagine the newbie running for this hills when starting out with a language like this.
PHP on the other hand, is definitely a more beginner-friendly language for those of us who are starting out. Being procedural helps.
As alway, looking forward to your practical, no-nonsense discussion and advice.
Jason
Comment by Jason — February 12, 2009 @ 12:36 am
Thanks, Jason, for the feedback and the nice words. Glad I could help.
Comment by Larry — February 13, 2009 @ 1:56 pm