Would you like to invest your time and efforts to learn a programming language that will no longer be relevant in a couple of years?
I have read two kinds of posts on the Internet. Those stating "Ruby is dead" and those who list Ruby as one of the top languages to learn.
To make up your mind and decide if Ruby is a good choice, you should rely on some facts about it, and that's the goal of this article.
Ruby is Object-Oriented, and not only.
Ruby allows you to design your applications using Composition, Inheritance and Interfaces. In Ruby, how the objects behave is more important than what the objects are. That's called Duck typing.
The best book on OOP in Ruby is Practical Object-Oriented Design: An Agile Primer Using Ruby by Sandy Metz.
It is also a dynamic language and has functional programming features.
What does Dynamic mean?
In short, it means that you can create methods and classes at runtime. That allows creating Domain-Specific Languages (DSL), which seem to extend the language with new functionalities.
For instance, let's consider ActiveRecord (the Ruby ORM to access Databases). It defines a DSL to create associations between models. In the following code:
class Author < ApplicationRecord
has_many :books
end
has_many
seems to be part of the language, but it is just a method that adds many methods to the model Author. Often people call this trait "Ruby Magic".
Friendly and active Ruby community
The Ruby community is welcoming, with various brilliant personalities, some of them quite opinionated too, and yes, DHH (the RoR creator) is one of them.
Yukihiro Matsumoto and the Ruby team are continually improving Ruby. They recently released Version 3, which is (almost) three times faster than version 2. That was an achievement since speed has been a weakness of the language.
Thanks to Ruby on Rails (and other web frameworks), Ruby stands out for Web development and API building.
A new Ruby on Rails version (the 7th) will be released soon. RoR is an old framework - the initial release was back in 2004 - but continuous updates make it modern, stable and suitable for a wide range of Web applications.
Rubyists are in high demand
Ruby is a niche language compared to Python, Java and Javascript. In my opinion, that is a strength. There are fewer Ruby developers, and there is a high demand for building new applications and maintaining old ones.
Some companies are happy to hire and train developers skilled in other languages to code in Ruby since Rubyists are not easy to find. I coached some Python developers to work on Ruby projects. They caught up pretty fast, even though there are few concepts new for Pythonistas - it is not just syntax.
In the UK, various Gov departments use Ruby in many projects. I've worked at DfE, MoJ and HMRC, and there is a high demand for Rubyists to maintain and expand those projects, which must continue to serve the citizens for many years.
Ruby is slow, or maybe not.
One of the criticisms to Ruby is about being slow. The reality is that, in a complex web application, speed is more than just choosing a fast language. The design and architecture of the whole system are involved. For example, I've seen web applications going ten times faster after fixing the N+1 queries problem. In that case, the language was not the cause of the speed problem. It was the poor way the app retrieved the data.
One last thing to consider is that in most start-ups, time-to-market is vital. At first, solving the problem and getting feedback from the users is more important than focusing on performance. A team that gets feedback early can quickly react to correct and improve the product.
That's why many start-ups are still choosing Ruby on Rails.
When Ruby is not a good choice
Finally, there are reasons not to choose Ruby. If you don't care about building web applications, look at other programming languages best suited to what you want to create.
To solve math problems and create Artificial Intelligence models, you should learn Python. Learn Kotlin to create Android apps or Swift for iOS apps. Javascript or typescript is perfect for building interactive Web interfaces. Of course, you can also use Javascript in the back end, but it might not be easy to maintain vast projects.
If speed is vital, Go, or Rust is a proper choice.
Those are just a few examples of choosing the right tool for the job. If web applications are your thing, then the time and efforts to learn Ruby will be worthwhile.