Comparing PHP to Ruby on Rails

Written by on Aug 25 2008

While trying to pick a consulting company to work with, people occasionally ask us about the differences between PHP and Ruby on Rails. Here are my thoughts on the matter. Please feel free to add to this list in the comments.

  • PHP is a programming language, whereas Rails is a framework for writing web applications using the Ruby programming language. So right off the bat this is not an apples-to-apples comparison.

    • There are a lot of PHP web application frameworks. Some are good and some are not (for some definition of the word good.) Many frameworks (including Java and .NET based frameworks) have borrowed heavily from Rails.
  • Ruby is a very succinct language. This means that you can be very expressive and do a lot in very few lines of code. PHP is very well known, so it might be easier for many people not familiar with Ruby to stay with PHP.

  • PHP programs tend to require less memory to run so they tend to be easier to deploy. With the release of mod_rails (Phusion Passenger) and Ruby Enterprise Edition Rails becomes easier to deploy than PHP once the initial Apache add-ons are made.

    • PHP programs require less memory because by default they don’t have the overhead of a web framework. Although I haven’t seen any stats on this, I would imagine that a PHP app running inside a web framework as robust as Rails would have similar memory requirements.
    • The additional add-ons only have to be made once per machine and are super easy to do.
    • Rails is easier instead of just as easy because Rails has migrations which make deployment of database changes easier than any open or commercial solution I have ever seen.
  • They are both equally easy or difficult to scale. The first level of scaling is just adding more memory/cpu/server instances. When scaling thusly they are both just as easy. Once this level of scaling is exhausted, they are both equally hard requiring all of the same methods as scaling any other web application on the internet: Code optimizations, caching, more servers, database scaling, content delivery networks and more.

  • Rails is cooler. Sorry, but it’s true. Don’t worry though, eventually there will be something even cooler than Rails and then I’ll write an article comparing that to PHP or Rails.

  • I’m sure there are exceptions to this, but in general the results of using Rails (final product) will be heads and shoulders (probably even arms and legs) above the results by someone who wrote their own web application framework.

  • The following would be true of any MVC framework (like Rails) worth anything, regardless of language:

    • Code is well encapsulated.
    • Anyone familiar with the framework should be able to pick up where someone else left off fairly easily.
    • Standards and best practices are well defined.
    • One should be able to do a lot with very few lines of code.
  • Things Rails does for you that seem to be specific to Rails (I would assume that somewhere there is another web application framework that does some or all of these things, but I am not aware of one).

    • Super easy to write a lot of code/test/functionality in record time. ## Database versioning.
    • REST/crud is very deeply ingrained.
    • Lots and lots of helper methods.
    • Significant JavaScript/AJAX support.
    • Very easy to extend.
    • Built in testing.
    • Vibrant community.
    • Lots of plugins.
    • Lots of blogs/tips/tutorials.
    • Lots of conferences/friends.
    • Very well tested.
    • Feels like it was written just for me (most of the time).
    • Easy for a designer to learn.
    • Because so much is done for me by the framework, I can spend more time working and thinking about the users and what’s best for them instead of things like rewriting my database connectivity stack.

My advice

Picking one over the other has more to do with who you trust to build your application for you and what they like. Or if you are a developer, find out which one best fits your tastes and temperament. Neither will save you from bad code or bad decisions or misunderstanding but for me Rails feels like home. Find something that feels like home and then go write something that users will love.

Here are a few things we’ve written using Rails: Less Accounting (web based accounting software) and Less Projects (project task tracking) (online project tracking)

Meet
Steven

Hi I'm Steven,

I wrote the article you're reading... I lead the developers, write music, used to race motorcycles, and help clients find the right features to build on their product.

Get Blog Updates