PHP and Ruby on Rails both have their very dedicated followers. These followers are so passionate about their chosen platform that gathering good information on the differences between the two can be pretty difficult. Yet this information is vital if you’re going to make a decision on which platform to develop your next project. Here’s a quick look at some of the core features and differences and some additional factors to consider when choosing PHP or Ruby on Rails.
PHP is a Language
Comparing Ruby on Rails to PHP is unfair. PHP is simply a programming language. However, it is an extremely flexible and useful language. PHP uses very little memory and performs quite well. It is also a mature language with a wide variety of extensions and library modules. Originally developed as a scripting language to be used in HTML pages, PHP has gradually matured and now includes full object oriented features. The later add-on of object oriented features is one of the biggest criticisms of PHP. Some programmers feel that PHP encourages sloppy coding because of its script-like roots and lack of a clear object oriented strategy from the beginning.
PHP, as a language, does not have all the features of Ruby on Rails. As a result, coding a site from the beginning in PHP requires a great deal more development effort since things like database connectivity must be coded from scratch. However, there are a number of mature and stable frameworks written in PHP that provide features similar to Ruby on Rails. This is one of PHP’s strong points — choice. The developer can choose the framework with only the features needed or develop the needed features himself. In working with Ruby on Rails, you are stuck with the features provided. This can sometimes make for a difficult development effort when the framework’s ideas about how an application should be configured do not match the requirements of the application. It can also cause performance problems when the framework takes more overhead than needed for unused features.
Ruby on Rails is a Framework
On the other hand, Ruby on Rails is a framework developed in the Ruby programming language. Ruby was designed from the ground up with object oriented design in mind. It has a very tight and clear syntax and programming in it can be down right elegant. It can also be extremely inflexible. As a programming language, Ruby often runs more slowly than PHP and requires more memory. Rails is a framework that provides a number of features that are useful for the rapid development of web applications. As a framework, Rails provides some great features. It supports the ActiveRecord design that maps database records to objects. ActiveRecord hides a lot of SQL code from the developer by handling a lot of the mundane tasks of creating, retrieving, updating and deleting objects automatic. Rails also includes a routing system to made URLs to methods and a templating system for generating HTML output. There are numerous other features including sessions. These features make it easy to build a web application on Rails.
Rails list of great features, is also part of its drawback. As a developer you lose a lot of control over the SQL queries in your application with Rails. You also use overhead to run features and services that your application may not need.
PHP and Ruby on Rails are about equal in terms of how easily or how difficult they scale to meet growing demands. On the spectrum of scaling they both benefit from increased memory and CPU but when an application requires load balancing or being served from distributed servers, the complexity grows. They both have similar requirements in terms of scaling and face similar challenges.
In the past, Ruby on Rails required more work to deploy but the modern situation is much easier. A new enterprise deployment system has made Ruby on Rails as easy to deploy as PHP.
The bigger consideration should be the development teams comfort with each. If you know PHP well and have worked with it for some time, learning Ruby will be a stumbling block. It makes no sense in terms of developer efficiency to use a new language or framework simply because there may be some minor gains. All of the features of the Ruby on Rails framework are available in PHP frameworks or can be developed using PHP. Developers should not be required to work in Ruby simply to gain access to some framework features. Developers write the best code in the languages that they know well.
Another important consideration is the rest of your platform. If you are using a large amount of PHP in other ways such as ad servers, modules or other add on components of your web site, it may make sense to continue to work with PHP. You should never underestimate the value of being able to integrate existing PHP code into your future work. Tighter integration is generally desirable in a web application. The platform that the bulk of your code is developed upon will likely guide you towards what platform you should use for your other development efforts.
And the Winner Is?
The clear winner is the platform that you already know, that will do what you need and that your clients need. In most cases, it is going to be PHP for a number of simple reasons. First of all, most web hosts support it so there are a lot more clients using it. You will find more jobs, more web hosts and more opportunities to use PHP. Secondly, the features that Rails as a framework provide, can easily be duplicated by using one of the many excellent PHP frameworks. CakePHP, in particular, supplies many of the same features. You probably already know PHP. Your existing knowledge can not be overvalued. Experience with a platform means that you already know all the pitfalls and gotchas of working with it. Finally, PHP is more flexible. If you don’t need a full framework, you can roll your own in PHP. If you need your application to work differently than what the framework defines, you can do that in PHP. And chances are you can find a library or extension to do anything you need to in PHP. While Ruby on Rails has some great features, the market has already declared the winner to be PHP.
Help us spread the word!
If you liked this article, consider enrolling in one of these related courses:
|Jun 05-06||Web Development with PHP/MySQL|
|Aug 07-08||Web Development with PHP/MySQL|
|- Classroom - Online|