Latest Posts »
Latest Comments »
Popular Posts »

How does PHP compare to Ruby on Rails, Django, Python etc?

Written by Bean on September 26, 2008 – 7:38 pm

This question came up recently on the PHP class boards about scripts and frameworks  such as Ruby, Django, Python, CakePHP and Symfony. I thought that it was worthy of some discussion here and moved the thread to the blog.

How does PHP compare to other server side languages? I’ve been reading up on it a bit, and it seems like some developers are quite antagonistic toward PHP, in favor of Django, Python, Ruby, Symfony, etc. instead. Do you favor PHP with MySQL? What do you think of Ruby on Rails or the other various combinations? I’m interested in developing web apps and am not sure where I should focus my attention. I’m new to all of this.

First, we need to make the distinction between scripting languages and frameworks. Frameworks are language specific tools that assist you in creating web applications, in particular database driven web sites. Pylons gives a good description of the components of frameworks.

  • something that generates HTML
  • something that reads arguments that are sent via HTTP
  • something that communicates with your database
  • something that contains your application logic
  • something that deals with user accounts
  • something that stores persistent data (like cookie-based sessions)

The big benefit to frameworks is that they come with libraries of frequently used code components that can save you hours in development time. Instead of writing something from scratch and debugging, you can pop in components and just customize arguments.

PHP frameworks include: Symfony, Zend, CakePHP, and CodeIgniter

Ruby framework is Rails

Python frameworks include: Django, Pylon, Turbogears

To utilize these frameworks, you will want to have at least a basic knowledge of the underlying scripting language. Ruby has been getting a lot of attention because it is object oriented and PHP has just recently entered the objected oriented programming (OOP) arena. Of the three, I think Python has the steepest learning curve for the base language but I have to admit that I haven’t played with it in at least two years. I think that Ruby could give PHP some competition down the road but not immediately. I see Python and Ruby being relegated to the  geek corner for awhile, while PHP continues to be the predominant scripting language.

Why PHP?

  • it is already installed on most web servers and works great with the most popular web server in the world, Apache. Ruby and Python often require separate installations and can be intimidating.
  • PHP is widely available on inexpensive hosting plans. Since Ruby and Python usually require additional installations, web hosting accounts with these languages installed tend to be more expensive.
  • Although all three languages have rich frameworks available to them, for every 10 shopping cart, forum, blog, content management, mailing list applications based on PHP you will find one or less based on Python or Ruby. It is much easier to add PHP applications to your project because you have so many choices.
  • Since there are many more trained PHP developers than Python and/or Ruby developers available, PHP web applications tend to less expensive to maintain.
  • Although PHP 4 was at a disadvantage, PHP 5 and 6 have greatly improved object oriented programming capabilities that challenge Python and Ruby. Although Ruby still exceeds in this regard, it is more complicated to install on a Linux system and retain all of the flexibility of the language and framework. It has a dramatically reduced number of applications to interact with as well.

This is just a brief summary of the languages and frameworks. There is considerable debate and programmers can become rabid fans of THEIR language/framework. I don’t believe there is just one answer to which is the best.  I do believe that PHP is the language to start with in terms of its learning curve, its widespread use and availability, its power and scalability and the sheer demand for PHP programmers. There is an interesting blog post and discussion at Killersites that reenforces some of the arguments that we present here.

Once you have decided which language to pursue, you can start testing out frameworks. They all have their strengths and weaknesses.  If you google them, you will find fans and detractors for all of them. You really need to test them out and see what matches your needs and workstyle. Other times your place of business will determine which framework they want to use. Frameworks do not necessarily play nicely with each other. As time allows we will try to post some reviews of specific frameworks. Check back later.

We welcome your thoughts and comments on this debate.


Tags: , ,
Posted in PHP | 4 Comments »
Programming Blogs - BlogCatalog Blog Directory