So, you want to build a web product from scratch, and you’re looking for the best web development platform. When it comes to web programming languages, it’s not that easy to make a choice which complies with your requirements.
In the following article, we're going to compare Ruby vs. PHP and find the main pros and cons of critical aspects of both technologies. The latest versions of languages are Ruby 2.7.0-preview1 (May 2019) and PHP 7.3 (May 2019).
Both languages are more than 20 years old, mature and proven in production. A lot of great products were created on their basis. So let’s look at these technologies from the beginning.
PHP invented as an HTML templating language in 1994 is now a reliable web development technology which can be used even for general purpose. In contrast, Ruby was released in 1995 as a general-purpose object-oriented language but is now mainly applied in the web development due to Ruby on Rails.
Although both programming languages initially had different aims, currently they are highly competitive technologies on the web development scene.
One of the main differences between Ruby and PHP relies on their philosophies.
The primary objects of Ruby were pleasure and productivity of developers who wish to work with stylish, elegant and flexible language.
I believe people want to express themselves when they program. They don't want to fight with the language. Programming languages must feel natural to programmers. I tried to make people enjoy programming and concentrate on the fun and creative part of programming when they use Ruby - Yukihiro Matsumoto, Ruby creator.
That’s why this language syntax is so elegant and beautiful. Developers love it and enjoy programming in it.
Coming back to PHP, it was primarily written for the personal purpose of Rasmus Lerdorf, its creator. Initially, he just wanted to count the number of visits to his online resume.
Well, I didn’t plan PHP. I think in terms of solving problems, not in terms of software projects. I actually hate programming, but I love solving problems - Rasmus Lerdorf
Soon, the simplicity of PHP attracted a lot of programmers in the web development world, and within several years it evolved into the first mass-market scripting language. But popularity had a reverse side. Due to rapid growth, it was tough to create a good language design. A lot of articles were written in that manner as "PHP: a fractal of bad design".
Many developers switch from PHP to Ruby or Python because the design of the two latter is much better.
We’re going to compare the following aspects of both web technologies:
- Learning Curve
- Cost of developers
- Speed and performance
So, let’s start our brief survey.
Subscribe to our monthly newsletter.
1. Learning Curve
Ruby code example:
PHP code example:
As you see, PHP example has an open tag
<?php. Now developers don’t mix any other parts of codes (like HTML or CSS) with PHP as before but still have to use such open tag at the beginning of the file. This action confirms precise compatibility with the oldest versions of the language.
Unlike the languages, frameworks have the steep learning curve. Even for experienced developers, it’s not that easy to effectively operate with several frameworks at the moment.
Recommended reading: SaaS Product Development: Why Choose Ruby on Rails Framework?
Let’s take a look at web frameworks.
In this table, you can find the main frameworks of both languages and the number of Github stars. As it shows, Ruby on Rails is the front-runner in the world of Ruby, while in PHP world, Laravel took over the show.
|Ruby Frameworks||Github stars||PHP Frameworks||Github stars|
|Ruby on Rails||43.2k||Laravel||52.5k|
The data is relevant for May 2019.
You may also like: 4 Useful Git Commands That Will Make Your Life Easier
While Rails is dominating over other Ruby frameworks, competition between PHP frameworks is much stronger because PHP gained popularity long before any other web development languages did it.
From the other side, Rails has gained the fame of the first mass MVC framework on the web. A lot of frameworks in many languages including PHP have copied ideas from Rails and Laravel was among them.
Ruby on Rails can be used for building various complex web solutions, including custom online marketplace development and SaaS development services.
There is a variety of online resources providing statistics on the prevalence of these two programming languages.
3.1 Sites written in Ruby and PHP
According to W3Techs statistics, PHP is an absolute leader in the number of sites written in it.
As we see, the total percentage of PHP use is over 79.0%. However, it is necessary to admit that such CMSs as Wordpress, Drupal, and Joomla cover a vast part of the PHP market.
3.2 Sites built with frameworks
BuiltWith.com shows that the Rails framework is more popular in comparison with PHP frameworks.
|Framework||Top 10k sites||Top 100k sites||Top Million sites||The Internet|
|Ruby on Rails||1,217||6,785||26,331||2,725,196|
As we see, the sites built in Ruby on Rails have the biggest numbers among all categories.
Related reading: 7 Reasons to Use Ruby on Rails for Your Startup
3.3 Programming languages ranking
As stated by Github report, Ruby and PHP are going very close by the number of repositories created in 2008-2018.
This Google Trends graph shows that PHP was of higher demand in the United States in 2018 and 2019.
Overall, although PHP is more popular among all sites, Ruby (and Rails) prevails over PHP by the number of developers’ activity on the Github and websites built with frameworks.
Many PHP projects were formerly written without any framework or reinstalled as copies of Joomla, Wordpress and Drupal systems. Whereas, a vast amount of custom projects and startups was created with Rails.
You may also like: How to Build a Website Like Airbnb: Step-by-Step Guide
A community built around a programming language represents an excellent force for developers.
Both technologies have great communities. One of the main distinctive features in Ruby vs.
PHP comparison is that Ruby has one community based on the Rails framework, while PHP has numerous communities fragmented depending on a framework or existing products.
In general, we can highlight three branches in the PHP community:
Developers who work with Laravel, Symfony, etc. frameworks and create projects from scratch.
Programmers who exclusively engineer in Joomla, Wordpress or Drupal systems. They are involved in the customization process of those products for their clients.
Developers who are aimed to maintain and support websites written before the emergence of modern PHP frameworks.
In this regard, it is fair to compare Rails developers and those PHP developers who work with frameworks. Consequently, the number of Laravel developers, for example, are less than Rails programmers.
In contrast, we can’t downplay the big circle which the strong Ruby on Rails community formed on Github. Together they focus on robust and high-quality development, making a significant contribution to collaborative efforts.
Related reading: 40 Best Ruby Gems We Can’t Live Without
5. Cost of development services
There is an opinion that PHP developers are cheaper and could be found easier than Ruby (Rails) developers.
The truth is that the price for the developers’ services depends on their qualifications, and the highly qualified programmers are well paid in both languages.
Actually, at the moment "PHP developer" term doesn’t exist as before. Right now we can talk about Symfony or Drupal developers, for example. And the cost of Rails and Laravel / Symfony engineers is approximately the same.
Below you can find Indeed statistics concerning job postings for both web technologies.
As it is shown, the demand level for the programmers of both languages was nearly the same.
But at the same time, demand level for Rails developers is higher than for Laravel which is the top PHP framework.
Recommended reading: What Makes Ruby on Rails Perfect for Marketplace Development?
6. Speed and performance
Now, all people in web communities do is compare Ruby vs. PHP technologies performance.
Having a look at history, we can find that Ruby and PHP used to have approximately the same speed at some points. But now PHP 7.3 speed is significantly improved. It is much faster than the previous versions. Excellent work, we have to say, now the ball is in Ruby court.
On releasing Ruby 2.6.3 in April 2019, the community introduced performance improvement comparing to earlier versions and presented other significant updates. In December 2019, the Ruby community is looking forward to releasing Ruby 2.7.0 available in preview now.
Although the developers tend to improve technologies performance, it’s not the reason to opt for any language just because of its speed. Hardware upgrade would be a more practical solution to the situation.
You may find interesting: How to Implement Elasticsearch When Developing a Rails Web App
Each of the given programming languages has its unique aspects and unique energy, serving the purpose for which they were invented. So let’s take a glance at the strong sides of both.
|Short learning curve||Short learning curve|
|Amazing developers` community||Huge developers` community|
|Great language design||Many frameworks available|
|Rails framework is the number one||PHP7 is very fast|
|A lot of information resources available||A lot of information resources available|
Just like the strengths, there are always some pitfalls in each language. Anyway, there’s still room for improvement.
|Runtime speed could be faster||Weak language design|
|Rails domination makes competition among frameworks weak||Problems in maintaining legacy applications|
When choosing between these two programming languages, you won’t find a definite answer which is the best one. Both of them have benefits and drawbacks.
Now PHP has improved performance, but its language design is still weak. Ruby needs some speed increase but has an elegant design and syntax. They both allow producing beautiful and robust web applications.
At Codica, we chose Ruby because we like the design and simplicity of this language. It helps us deliver successful web solutions to fit our customers needs best, as well as provide end-users with web products they love. For example, take a look at this multi-vendor vehicle marketplace case study which we built for the African market.