Laravel VS Ruby on Rails.

Since a lot of people come to this blog searching for the answer if Laravel is better than Ruby on Rails, I will post a short biased comparison of the two, and I will tell why they shouldn’t be compared.

I had started developing web applications about two years ago in one of my classes at the university. The number one web development tool at that time was Ruby on Rails.

When the teacher(the most awesome teacher I had at school) showed us what you could do with Ruby on Rails and how quickly it could be done, it was like magic to me. I didn’t believe that RoR could be so intelligent, it’s like you feed almost human-like language into it and it automagically spits out a nice web application at you. I developed a few small applications with Ruby on Rails, one is an interactive seating chart with a backchannel (kind of like chat) and another one is Clicker-like online polling, the two are located here: http://severe-dusk-953.heroku.com/ and http://young-mountain-432.heroku.com/ and their sources are at https://github.com/msurguy/CS-473-Clickaz-app and at https://github.com/msurguy/seatingchartAJAX

I was really passionate about Ruby on Rails at the moment. I watched screencasts on Railcasts, I read lots of Ruby on Rails blogs, followed top contributors’ posts and attended local Ruby Meetups. The culture was really awesome and the environment was encouraging. I bet if school didn’t get in the way with other priorities I would’ve continued doing stuff with RoR.

After the class and after the initial amazement about RoR I started to face problems with even simple things and I had no quick answers that I needed to keep pushing forward so I slowly lost interest. When I wanted to start over there was no quick way to get RoR running on my brand new computer, so I again postponed development with RoR.

Fast forward a year and a half, I was working with a startup and it came to a point where I needed to choose the right framework to build the product on. Ruby on Rails came first to mind but I remembered how much pain I had just getting the thing running on my local machine and how hard it would be to find somebody near me that could do really great RoR coding. I decided to stick with PHP and looked in those waters instead. A few days and over two dozen frameworks later, I found something that seemed clean enough, not overbloated, with a great community and with great simplicity. Sure enough, it was Laravel.

Why? With Laravel I developed an application within the first hour of actually discovering the framework, without any prior experience with PHP frameworks. It was a breeze to get it up and running on my local machine, actually on both PC and Mac. It has very eloquent and expressive syntax, just like Ruby on Rails, and in my opinion the structure is cleaner in Laravel.

Both RoR and Laravel use ORM that simplifies database queries. I don’t know how good RoR is right now to say about its ease of use with all kinds of databases. Laravel supports the following databases out of the box:

  • MySQL
  • PostgreSQL
  • SQLite
  • SQL Server

Both RoR and Laravel have addons, in RoR they are gems in Laravel they are Bundles. Easily pluggable into your application.

In RoR : gem install nameofthegem

In Laravel: php artisan bundle:install nameofthebundle

Both RoR and Laravel are MVC frameworks to keep the structure of the application separated but I think Laravel is more forgiving about that and sometimes that could be a drawback since the code can become un-pretty if the developer isn’t experienced. But hey, at least the developer wouldn’t be discouraged because the code will still work!

One major selling point of Laravel for me was the human-friendly documentation. I remember in RoR I had to dig through a ton of online examples and climb on shoulders of others before I could find the answer I am looking for. I never even dared to look into the inner workings of Rails.

With Laravel the documentation is as clear as it could be, with lots of real examples that could be easily modified to suit my needs and developed upon. It brings joy to my heart to see an easy example for each subtopic in documentation. Like this:

Route::get('user/(:num)', function($id)
{
    //
});

Laravel itself is written in such a way that it welcomes others to look at what’s inside. The online API  is just as clean as the documentation, simply a huge help for the developer.

Maybe there are so many books and tutorials about RoR because people have trouble understanding it in depth to figure stuff out? I don’t know…

I admit that I came to PHP world being spoiled by the magic of RoR, so in Laravel I found that what I didn’t experience with Ruby on Rails, being able to go from zero to an application in ridiculously short amount of time. The magic of developing was again found for me, though in a different world from RoR.

In my opinion RoR and Laravel shouldn’t be compared. They are two different platforms, two different ecosystems, they both have lots of good things about them and since nothing is perfect they also have their drawbacks. The choice should be only yours, try out both things and see how quickly you can build a great application. I made the choice based on experience, not on just what others tell me, and I would encourage you to do the same!