Nov 15, 2021

The journey from PHP to Ruby

Zakirdin Lamiev
Zakirdin Lamiev
Shahadat Rahman
The journey from PHP to Ruby

I got acquainted with PHP and started my developer’s career in 2013, when I was a 3rd-year university student. I received an offer to work as technical support engineer in a company that had a self-written framework in PHP. Three month later, I moved to another department and became a proper developer - a PHP Software Developer.

I’ve gone to work for several different companies during my career, working with different frameworks, touching various architectural designs, and one thing remained always the same - my main tool has always been PHP.

PHP - the good, the bad and the ugly

My journey with PHP covers the full range of human emotions: from excitement to anger. There are a lot good things about PHP in this mix of memories — the migration from PHP 5 to PHP 7 vastly improved the performance of the framework, for example. The rise of Symfony, Laravel, and a bunch of other cool frameworks and instruments. And the last one, the enterprise Magento with its enormous codebase and steep learning curve. I love PHP’s PSRs, but I hate PHP’s tangled mess of function names and arguments.

I think PHP is a good language and tool, no matter what others say. Some developers believe that the language is stagnating, and PHP devs still write fully-procedural code as they did in PHP 4. But, the current version is PHP 8, and it’s far from dying. It has a high number of different frameworks/projects, it’s easy to learn, and a large community stands behind it — in the 2020 Stack Overflow survey, PHP took 8th place.

My new-old buddy Ruby

In 2020, I decided that it was time to move on, and I applied for an open position in the Backend team at Showmax Engineering, and was accepted. In my new position, I was expected to work with Ruby and they were ok with me learning it as we went. This was not my first experience with Ruby, as I had been a Ruby-ista at the first company I worked for in 2015. However, after 5 years, I had forgotten almost everything about development in RoR and Ruby. Only the feeling of a neat, easy, and mature software development process remained.

Ruby is a joy

Originally, Ruby was developed to be an easy, truly OOP language. Compared to PHP (which initially was just a bunch of scripts), it has a cleaner design and more thoughtful architectural decisions. Ruby was not created to be the most popular language, nor the best-performing one — the main idea of Ruby was to make programmers happy when working with it.

“Ruby is making developers happy, productive and enjoying programming.” — Yukihiro Matsumoto, the chief designer of Ruby

I understand why some people are attracted to Ruby — its syntax allows developers to write code that semantically is very close to natural human language. It’s simple and predictable.

Have a look at this:

word.capitalize! if word.end_with?("ipsum")

The code performs exactly what you would expect: “Capitalize the word if the word ends with ‘ipsum’.” It’s beautiful, isn’t it?

As for rumors of Ruby’s impending death, it’s definitely not as popular as it was in the early 2010s. However, gems are being maintained, projects are being developed on RoR, and Ruby is still actively developing. In 2020, the 3rd version was released, and it has improved performance, concurrency, and they added static analysis. Matz and others are working hard on Ruby and I do not see any reason to shelve it. From another source, head hunters are still searching for experienced Ruby developers — clearly, Ruby is not dying!

The only thing that I miss in Ruby is abstract classes and interfaces. In my opinion, any and every programming language should grant developers a chance to think more about architecture than specific implementations.

Rails is where it all begins

Let’s have a look at how Ruby and Rails has influenced the world of web programming with its ideas. After its release in 2004, it earned great popularity among both developers and entrepreneurs as the ease and speed of building and deploying applications in Ruby were both way ahead of other frameworks of the time.

Coding, tests, deployments, and more work out-of-the box thanks to Ruby on Rails’s “Convention over configuration” paradigm. Currently, this development paradigm can be found almost everywhere — Java with Spring Boot, PHP with Symfony or Laravel, C# with ASP.NET, and so on. It speeds up and improves the development process tremendously, while code remains clean and maintainable.

Other fancy stuff such as scaffolding or metaprogramming that can be found currently in almost every framework were also adopted after RoR success. These days, developers won’t be surprised or impressed by such features.

RoR is still bold and rigid, it evolves and grows, and it handles its work well. The Riding Rails news website is regularly updated.

Tests - to be or not to be?

In PHP, you can find PHPUnit, Behat, PHPSpec, and other testing solutions, however the usage of tests in real life could be way higher. In the world of PHP, it’s common for developers to skip testing fully, or at least partially. On the contrary, Ruby and Ruby on Rails rspec is a “must have”, and Ruby developers always tend to write tests. For the developer who follows TDD and BDD, that’s a big win.

The Future - it’s brighter than it seems

As a PHP developer, I’ve heard all the “PHP is dying” talk, but I know that it’s not true. Someone who is out of the PHP infrastructure world could think so, but now we have PHP 8 with JIT and performance that competes with NodeJS. In short, it’s far from being dead. I think the same thing is happening to Ruby. It’s not as hyped as it used to be, but it still helps companies and start-ups create awesome things. Just give it a try!

Share article via: