Thunder Data Systems

Rails vs PHP

Rails vs PHP

Though you hear it all the time, comparing Ruby on Rails to PHP really is not fair – they are different animals entirely, only sharing the goal of creating websites that do stuff.

Rails, being a framework, could be more aptly compared to PHP frameworks, such as CakePHP, or Zend View. But even then they are still very different – and the difference is Ruby.

Ruby is beautiful, elegant and easy to read. PHP is pragmatic and direct but disorganized (imho).To Ruby, everything is an object, which serves as a good organizational mechanism. In PHP everything is a global function, usually with funky names that give little indication to what it does. It is like the difference between an organized toolbox, with all the right tools in all the right places and one big box with all the tools thrown in haphazardly.

Let’s look at a overly simplified example of some Ruby code, often used in Rails.

What do you think that means?

Let’s look at it in PHP.

time() – 86400;

Hmm, I think most of us could figure out the PHP but anyone could read the Ruby. Which brings up another subject. The Ruby code above is actually an extension of a core class/object in Ruby, which Rails does – a lot, to great effect.

There are many more/better reasons for choosing Ruby and Rails, of course. But, for me, it is the simple things that Ruby allows which makes Rails … different and better.

Leave a Reply

Your email address will not be published. Required fields are marked *