The clash of titans: Airbnb and Basecamp versus Facebook and Yahoo! The first two were built with Ruby on Rails, the next with PHP. But whose right? What side are you on?
Now, let’s bring some more context to our topic. Rails, Ruby, PHP...for those less initiated, the differences are a bit blurry. But let me clear this for you: PHP is a programming language while Rails is just a framework on top of Ruby language. It’s as simple as that.
But what makes people so confused around the topic? Firstly, Rails may be only a framework, but it is what makes Ruby popular and strong. There are of course some alternatives like Sinatra, Cuba or Padrino, but they are rarely used and fade in the shadow of their bigger brother.
Rails is still the main core of web development with Ruby and it doesn’t look like things are about to change in the following years.
PHP on the other side comes with many widely used frameworks - Laravel, Zend, Symfony and many more which encourage creators to compete with the others on the market.
So to begin with the comparison one should start with looking up close to the main cores and roots of those technologies: PHP and Ruby themselves.
Ruby vs PHP: the Pros and Cons
They both appeared in the middle of the ’90s. PHP (Hypertext Processor), gained popularity surprisingly quickly, becoming the most preferable way for web development for a long time. It was made as a script language with general-purpose being flexible, fast and pragmatic.
Ruby on the other side was made with more general-purpose focusing on simplicity, productivity and elegance. It is said that reading Ruby code is almost like reading normal English sentences.
At the very beginning, it was used more for fun or side projects than serious development. It all changed when Rails appeared in 2003, luring developers to fresh, fast and breaking solutions that Rails offered.
Now, let’s look a bit at the strengths and weaknesses of Ruby.
Next, on Baywatch. How about PHP? What are the features that makes it so tempting for developers? And what are the facts that give developers a headache?
Behind Ruby and PHP: The Frameworks, Performance, Tools and Support
Languages are of course the main core of every application, but programmers, being in most cases quite lazy people, love to use ready-to-go solutions. Why would you even want to reinvent the wheel over and over again with every project? This is where frameworks come in handy. Usually considered as a bunch of packages/libraries or gems that work together to allow better code quality, stability, speed of development and many more.
With millions of developers totally spread all over the world with different principles and ideas, PHP can be proud of the amount of libraries and frameworks that you can use. Only problem is that with the enormous amount comes large difference in quality of those. Let's focus on the brighter side of the moon:
- Symfony - Framework and set of reusable technologies and libraries. Started in 2015 as an open-source. Was made to speed up maintenance and creation of web apps as well as to replace repetitions.
- Laravel - released in 2011, has become a leader amongst PHP frameworks for web development. It follows the model-view-controller pattern and is based on and synced with Symfony. This connection may lead to the need of changing a lot from version to version just to keep up with Symfony. Changes like that cost tons of time for developers to adjust and are just annoying.
- CodeIgniter - noted for its speed and performance in comparison to other PHP frameworks. Simple and elegant.
- CakePHP - framework written for faster development. Based on RoR concepts and principles.
Can happily announce better overall quality of gems and frameworks, but losing due to their amount with PHP. The question is, what is more important? Quality or quantity? Here comes the king and the only one that looks promising to overtake the throne in several years in rubys kingdom:
- Ruby on Rails - the framework that has made Ruby so popular. Widely used especially for startups.TheRoR community has been setting trends in web development for years (like the model-view-controller pattern or convention over configuration). Released officially in 2004, it started in fact in 2003.
- Sinatra - “Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort”. Nowadays probably the best alternative for Rails in the Ruby’s community, although still falling a lot behind. Sinatra may seem a better choice for smaller applications.
Ruby was considered a slow language. It has been labeled as one over a decade ago, when Twitter changed from Rails to Scala, arguing their decision with Rails having scalability problems as well as issues with the performance itself.
Nowadays Ruby has almost totally fixed problems of the past. PHP 7, although, is still way faster than Ruby in most cases.
When it comes to frameworks, Laravel mostly wins with Rails. It can handle way more requests per sec. And it’s generally more efficient in concurrency. The question is, will your project ever be so overwhelmed that choosing the right framework will have a significant impact?
In about 95% of cases, it will make no difference whatsoever, as long as you are not creating another Twitter of Facebook with millions of calls per minute.
We also have to remember that developers themselves have a huge impact on the speed of the application. The unskilled developer, even with the fastest tools, will make a mess and slow down the project even up to 100x times.
The Development Speed
Here comes the part which is more dependent on the framework itself than the language, as that’s one of the reasons why frameworks appear - automation and speeding up the whole product creation process.
PHP has many awesome frameworks, that compete among each other. Ruby, on the other hand, is governed by Rails, leaving competition far behind. Thus for the sake of your reading time and common sense, I will compare the 2 most popular and promising in both languages frameworks - Laravel and Rails.
Laravel’s development speed is scored as extraordinary fast, but Rails here prevails, same as it did a decade ago with other frameworks. Rails is highly focused on delivering the project asap. Rail is still the leader as well as an example to follow for other frameworks.
Both Laravel and Rails implement, for instance, scaffolding - a way to automatically create files filled with ready to work code only on some basic assumptions and parameters. It allows to almost instantly set up the project skeleton. Thus why RoR and Laravel, not without a reason, are used for startups and MVPs.
The Tools for Developers
From this point of view, PHP is by far the winner. Ruthless, robust, advanced, light and fast, open source or enterprise, PHP has it all. The realm of PHP is made of Eclipse, NetBeans, PhpStorm, Aptana and many, many more IDE-s that might come in handy depending on the complexity of the project.
For years, the PHP community was supported by many companies, resulting in an enormous amount of professional tools. Rails, as the one less popular and dependent on open-source and the community, lacks tools and commercial backup. It handles the lack of it with many gems that help with automation of code production and deployment.
The Support & Learning
Ruby is in general harder to learn than PHP. For many developers, PHP is the first web language they learn, while Rails is quite often chosen by those with more experience who want to learn a new language.
Mastering PHP requires less effort, but Ruby offers better code quality and leaves an open door for experimenting. Transition, if any, in almost all cases goes from a PHP developer to a Ruby developer, not the other way around.
As for the support PHP has a lot larger community and a broader range of technologies and libraries, but Ruby seems to have more committed fanatics focusing mostly around Rails. The Ruby gems and frameworks, due to code readability, are mostly self-documentary, while the PHP packages require additional explanations.
For both languages, there are tons of docs and tutorials on how to develop, both constantly growing. Same goes for Laravel and Rails, with the former having one of the fastest growing communities. They both score as the 2nd and 3rd most developed by community frameworks on GitHub:
World-known Apps Built With PHP or Ruby
PHP - According to w3techs.com about 80% of webpages nowadays are made with PHP. PHP leaves competition far behind mostly due to web creators like WordPress, Joomla, Drupal etc. We have to also remember that web apps can be made using many languages at once.
This one needs no description. Worlds biggest social network and 3rd most visited website (after Youtube and Google) that have taken over the whole world, leaving the competition far behind.
Search engine website, used by around 627 million unique users per month. Large part of it is made with PHP.
World’s biggest multilingual encyclopedia. It’s free to use, edit and contribute for volunteers.
One of the most successful image hosting platforms. As stated on Flickr website: “home to tens of billions of photos and 2 million groups”
- WordPress - Most popular Content Management System (CMS). It’s free and open-source. Mostly used for blog creation but has a lot more to offer.
PHP may have a lot more websites out there, but Ruby scores the fastest growth according to w3techs.com :
Accomodation-sharing website with 150 million (including 640 000 hosts)
Top e-commerce platform that helps businesses start, run and grow. 600 000+ merchants and 1.2 million+ active users.
- Basecamp Root and origin of Rails, still setting the trends in community. It combines all that teams ever need to work efficiently into one tool. Emails, chat threads, docs, idea, plans all merged into one for increased performance. Basecamp is used by roughly 3 million people as a project management tool.
Rails and Laravel are both amazing frameworks. They have a lot in common - core principles, dedicated communities, fast development. True differences lie in fact more in languages they enhance - PHP and Ruby.
It is yours to decide which one would you choose for the project. When it comes to productivity/time it’s hard to find a better solution than Rails, especially for startups or MVPs, but also keep in mind that Laravel is a worthy, much younger rival.
The absolute truth is that no language or framework is ever going to compensate for poor programming and architectural decisions, so make sure You choose the best team you can get! A skilled programmer will develop high-quality product in any framework/language, because core principles stay the same.
Think of it like that - true master lumberjack just with an axe will cut more trees, more efficient way and predicting the aftermaths of every tree fall, than a newbie with a top-notch chainsaw just trying to do it ASAP (omitting obvious safety issues in that case and assuming the youngling even knows how to use it).
Interested on reading more about Ruby on Rails? Check another of our blog posts regarding Rails itself, as it is definitely one of the best frameworks to build an application of your dream!