MVC on PHP and a quick comparison to Ruby on Rails

I’ve read a few articles written by PHP developers who feel that Ruby on Rails represents the latest and greatest in web development languages. After learning about Ruby a bit more, I realize that it’s no better than using PHP with an MVC framework. With PHP, you can choose your favorite MVC framework. Depending on your needs, with PHP you can choose CodeIgniter, Zend Framework, CakePHP, MicroMVC or a variety of others. If you choose Ruby, you can also choose your favorite framework, however Rails is the most prominent and the one that most books and publications cover.

I can think of some advantages and disadvantages to having your choice of frameworks. Advantage — You can pick the framework that best suits your needs. Disadvantage — You have to take the time to learn enough about each framework to make a choice. Advantage — You can choose to NOT use a framework, thus making your code faster and more effecient. Disadvantage — It’s difficult to combine code from two different projects that are written on two different frameworks.

Ruby on Rails deserves much credit. Anyone who has ever developed a web site knows that there are bits of code you use over and over again. Ruby on Rails, being developed for the purpose of building web sites, makes available some great APIs for getting common tasks done quickly. Ruby Gems are a way of packaging code into a reusable, easily distributed bundle. Gems are great since developers can encapsulate their code easily, this making it easy for other developers to implement. Ruby on Rails is also fully object oriented, whereas PHP is not.

What it all boils down to is that Ruby on Rails is like the Hybrid car of tomorrow. Developers consider ROR to be the sexy new language of the future. Nevermind it’s features or how it works, it’s new. Where does that leave PHP? I suppose it’s place is as the old, outdated language that’s falling by the wayside. Quite the contrary, would one consider unix to be old and outdated? After all, it’s over 30 years old. Anything that old in the computer industry must be old and outdated. But it’s not. In the computer industry, we call unix “mature”.

That’s what PHP is. It’s a mature language. It has a robust set of APIs. It has a broad following. It has plenty of open source backing it. It runs on the majority of servers on the internet. It’s fast. It’s secure. It has all the things you would expect from a mature, robust language.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Twitter

6 Responses to “MVC on PHP and a quick comparison to Ruby on Rails”

  1. Patrick Nelson  on March 5th, 2009

    PHP is where it’s at. I’m totally with you on that — but I’m biased! PHP is a great interpreted language — the language itself was written FOR the web, not adapted from another language. Ruby REQUIRES a framework to work well as a web app development language (otherwise, you’re stuck using CGI to execute Ruby scripts). The fact that PHP was already written for the web means that it already contains low-level constructs and built-in functions/objects that work very well with handling common web-based tasks. Plus, it runs VERY quickly (albeit I don’t have a benchmark comparison between RoR and PHP).

  2. wojak  on May 2nd, 2009

    There’s no problem to run only ruby without rails, all You have to do is some fcgi dispatcher (also available). Ruby is faster than php in many cases. There is more advantages of use Ruby instead of PHP, than to use PHP. It’s like PHP is chaos, and Ruby is harmony. :) Take a closer look at it. I was sceptical for long time…

  3. admin  on May 12th, 2009

    I doubt Ruby is faster than PHP. Especially PHP with the Zend Optimizer running. If it is, the speed difference would be nominal. I’ve learned enough about ROR to know that it’s a fine, well written language for web development, but I couldn’t see any reason for a well versed PHP Developer to make the switch. I’ll offer this… ROR is eerily similar to running PHP with CakePHP, so if given the choice between the two… what would make a person want one over the other?

  4. Patrick Nelson  on May 12th, 2009

    To play devil’s advocate — RoR offers a singular framework that is incredibly powerful and widely understood. Everything is completely OOP. Generally, the reality is RoR provides more power than is often needed for typical website projects. I’d like to add, though, that PHP can probably provide the same level of functionality, flexibility and commonality (ie single “framework”) that RoR could as well. I definitely find that PHP seems somewhat chaotic and very odd to most old school OOP lovers, but — PHP is definitely growing and expanding in the OOP arena as well. For example, PHP now has name space support — that’s a huge plus for those looking for freedom/flexibility.

    Ruby is a much more mature language, though — it can do quite a lot. I’m personally much more comfortable with the C/Perl style syntax of PHP and PHP is more than fast enough for me and is still very advanced. RoR just scares me because it’s so wordy and reminds me (in appearances only, albeit vastly different) of VBScript from the old ASP days.

  5. Patrick Nelson  on May 12th, 2009

    PS: I’ve looked at this for quite a while. There’s still a lot of debate over which is faster – PHP vs RoR – but there are clear arguments that debunk benchmarks that favor one or the other. Arguments generally are about overall scope (IE: Building a sort algorithm instead of using built-in algorithm), overall use (IE: benchmark is fast in a limited test, but production is faster/slower) and efficiency of code written in comparisons.

    Another thing that must be factored in that’s VERY difficult to measure accurately AND objectively are factors regarding preference — what’s easier to read, easier to write (less wordy, etc). Development speed too — RoR is good because it offers a ready-to-use framework AND if you’re a RoR developer going into another RoR project you’re not familiar with, you’ll pick it up quickly. Not quite the case with PHP!

    Simply put — to me, it’s like comparing apples and oranges. Which one is better? It depends on who you are and what you’re doing. Bottom line.

  6. byron  on July 29th, 2009

    There is certainly a lot of karma around running ROR, but the whole process of just getting a Rails project started up scared me away. I do like how with PHP, you just throw a page out on the server and call it in a browser and you’re off to the races.

    And if you aren’t worried about GPL’ing your project, and the overhead doesn’t scare you away, you can build virtually anything in the world you want on top of WordPress, which has a fully outfitted kitchen in addition to the kitchen sink to get you started. Just have the User Administration and publishing pieces make it work for me.

    I’ve done a bit with Code Igniter, which is a nice MVC framework, but I absolutely hate writing a User Admin module. So, PHP and WordPress have me hooked. I really liked Code Igniter’s Active Record implementation. WordPress uses ezSQL, which makes the DB side very simple, but not quite as tricked out as Code Igniter’s Active Record.

    Cheers,
    Byron


Leave a Reply