Company logo | Codica

Ruby and PHP: which is the best fit for your startup?

June 25, 2019
7 min

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.

History

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.

Philosophy

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.

Comparison list

We’re going to compare the following aspects of both web technologies:

  • Learning Curve
  • Frameworks
  • Popularity
  • Community
  • Cost of developers
  • Speed and performance

So, let’s start our brief survey.

1. Learning Curve

While studying Ruby or PHP, both technologies have a short learning curve. There are a lot of online interactive tutorials, for example, Learn PHP or Try Ruby.

Ruby code example:

odd_numbers =[1,3,5,7,9]
odd_numbers.eachdo|odd_number| 
  puts odd_number
end

PHP code example:

<?php$odd_numbers=[1,3,5,7,9];foreach($odd_numbersas$odd_number){echo$odd_number."\n";}?>

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?

2. Frameworks

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 FrameworksGithub starsPHP FrameworksGithub stars
Ruby on Rails43.2kLaravel52.5k
Sinatra10.6kSymfony20.8k
Hanami5kCodeIgniter17.3k
Padrino3.2kYii212.9k
Phalcon9.7k

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 product development services.

3. Popularity

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.

Statistics: usage of server-side programming languages for websites

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.

FrameworkTop 10k sitesTop 100k sitesTop Million sitesThe Internet
Ruby on Rails1,2176,78526,3312,725,196
Laravel2081,3258,4641,086,108
CodeIgniter737108,123908,389
CakePHP412751,924198,545

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.

Top programming languages by Github repositories created, 2008-2018

This Google Trends graph shows that PHP was of higher demand in the United States in 2018 and 2019.

Google Trends on Ruby and PHP demand in the USA

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

4. Community

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.

Indeed statistics 2014-2017: job postings Ruby vs PHP vs Ruby on Rails vs Laravel

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

Advantages

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.

RubyPHP
Open-sourceOpen-source
Short learning curveShort learning curve
Amazing developers` communityHuge developers` community
Great language designMany frameworks available
Rails framework is the number onePHP7 is very fast
A lot of information resources availableA lot of information resources available

Disadvantages

Just like the strengths, there are always some pitfalls in each language. Anyway, there’s still room for improvement.

RubyPHP
Runtime speed could be fasterWeak language design
Rails domination makes competition among frameworks weakProblems in maintaining legacy applications

Summary

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.

Are you looking for a custom software development company that can help you with a Ruby on Rails project? Let’s get in touch!

Article contents cta | Codica
Where Ideas Thrive
Bring your vision to life with a highly engaging and unique web application that your users love.
Learn more
Frequently Asked Questions
Dmytro CEO | Codica
Dmytro
CEO
Dmytro is a software entrepreneur with 20+ years of experience focused on the Lean Startup approach. He loves helping startups build excellent custom products.
Authors details
Rate this article!
Rate this article | CodicaRate this article full | CodicaRate this article | CodicaRate this article full | CodicaRate this article | CodicaRate this article full | CodicaRate this article | CodicaRate this article full | CodicaRate this article | CodicaRate this article full | Codica
(0 ratings, average: 0 out of 5)

Related posts

Stay up-to-date and never miss a resource

Subscribe to Codica newsletter

Latest posts