CSC/ECE 517 Summer 2008/wiki2 1 mf

From Expertiza_Wiki
Jump to navigation Jump to search

Ruby vs PHP

While Ruby is fast growing in popularity, there are still more PHP Web applications communicating with MySQL dataases. Compare Rails with support for Web applications in PHP. Which are the advantages of each for the developer? For the finished application?

An unfair comparison?

I feel that I must start off with a cliche comparision: comparing Rails to PHP is like comparing apples to oranges. Heard that one too many times? Well it definitely applies here. Rails is a web framework for the Ruby programming langauge. PHP is a web scripting/programming language. Notice the discrepancy?

Because of this discrepancy, many of the comparisons made by me in this document are not Rails to PHP comparisons, they are Ruby to PHP comparisons. Luckily this doesn't derail us too much. (horrible pun intended)

Advantages for the developer

Ruby on Rails

  • Rails is easy to develop - With so many common features built in and a very logical language set Ruby on Rails is one of the easiest languages to pick up out of the blue and rapidly develop.
  • Ruby code is nice and concise - Many operations that take multiple instructions in PHP can be done with one in Ruby. Best example: iteration.
  • The framework takes care of a lot of the thinking for you - Model handles database interaction, check. Controller handles processing of input stimulus, check. View provides the interface, check. It is incredibly plainly set forth how to build a Rails web application.
  • Ruby is the epitome of OO - Everything in Ruby is an object, everything. Ruby was specifically built around this principle. This doesn't seem too big a deal unless it is also pointed out than many PHP sites still employ PHP4 which is very outdated and its OO support is shoddy at best.

PHP

  • Availability of code snippets, assistance, and documentation - PHP is a much more popular and widely used language than Ruby on Rails. With that comes the huge advantage of a large developer base: near limitless help and support for a problem that some else has much more than likely already experienced.
  • Like MVC? - If you like the MVC architecture then guess what, PHP has that too. Because of the huge user base many people have derived their own frameworks like CakePHP that provide you what you think you may miss by straying away from Rails.
  • More control - with PHP you are not stuck trying to make your application fit a framework. You can make you application do what you want however you want to do it. If you are good at what you are doing you can still have beautiful code without a strict framework trying to get you to design/develop properly.
  • PHP looks familiar - Know C, C++, or Java? The syntax is very familiar in PHP which makes the switch very easy. Know *nix commands? A lot of them are functions in PHP that do what you'd think that they do. This makes ramp-up time in PHP very quick for an already seasoned programmer and/or *nix user.

Advantages for the finished application

Ruby on Rails

  • Rails is easy to maintain - Sharing quite the same reason as being easy to develop, Rails is very readable and easy to pick up. You can eyeball code and know what it does. The framework also aids in this because you know exactly where to look for the functionality that you need to add to or revise.

PHP

  • PHP Scales

References