Why choose Ruby on Rails for development

Why choose Ruby on Rails for development?

Kaja Grzybowska

Let's be honest: Ruby on Rails may not be the hottest programming language on the market, as shown by the TIOBE Index and the RedMonk Programming Language Rankings. There is no point in pretending that it has a chance to achieve stardom any time soon. Yet, if we delve into a discussion deeper than the superficial "hot or not" level, we must acknowledge that Ruby on Rails has advantages that position it as a valid alternative to more recognized competitors.

What is Ruby on Rails and how does it differ from Ruby?

Ruby on Rails, commonly known as Rails, is an open-source framework for web application development, crafted in the Ruby language, and so - there is a difference between Ruby and Ruby on Rails.

Ruby origins

Ruby is a general-purpose, object-oriented programming language. Launched in 1995, it quickly became known for its simplicity, readability, and productivity. Ruby's syntax is similar to Perl and Python, and the language is used to develop a variety of applications, including desktop and web applications. 

It was invented by Yukihiro Matsumoto, known simply as "Matz" in the programming community. Matsumoto's goal was to create a truly object-oriented language, as he believed the ones that already existed were not sufficient. He considered Perl to be a "toy language" and viewed Python as not truly object-oriented, saying, 'OO features appeared to be an add-on to the language' in 1999.

Finding himself at a dead end, Matsumoto decided to invent his own solution. He gathered all the features he loved most, such as iterators, exception handling, and garbage collection; and wrapped them up under one hood. This is why it is hard to point out the most significant predecessor of Ruby. It is influenced by multiple languages, including Perl, Smalltalk, Eiffel, Ada, BASIC, Java, and Lisp.

Ruby on Rails origins

Ruby's rise led to the development of a new server-side web application framework. Ruby on Rails was created in 2003 by David Heinemeier Hansson, back then a programmer at 37signals (now Basecamp).

Hansson was working on the codebase for Basecamp, a project management tool, when he extracted some features to make it easier for other developers to build web applications with Ruby. What exactly is Ruby on Rails (RoR or Rails)? It is a framework written in Ruby. RoR is based on the Model-View-Controller (MVC) architectural pattern and is known for its emphasis on convention over configuration (CoC) and the Don't Repeat Yourself (DRY) principle.

In essence, Ruby provides the language's syntax and features, while Rails uses these features and adds tools and conventions to streamline web application development. Rails is completely dependent on Ruby, but Ruby can be used independently of Rails.

Ruby on Rails current state

According to the TIOBE index, Ruby began at the 22nd place in the list of most popular technologies used around the world, later it grew significantly, to 11th place by 2019. However, it lost 4 places since then and stood at 15th place in 2020.

2004 was the time when it shined the most. This was when many major companies, such as Shopify, started using RoR for their web development needs. After that, it continued to be a popular choice for several years, but later its fame seems to be fading away. 

What has changed? Well, mainly the perception. The core of this technology focused on productivity remains the same, but the emergence of other technologies and frameworks, such as Node.js in particular, caused the reshuffles. The major companies started to lose interest in RoR, and for example Airbnb recently announced that they're moving away from Rails in favor of React and Node.js, and GitHub began gradually transitioning to a service-driven architecture, incorporating additional technologies such as Go, Java, and Rust. However, Rails still remains a core part of its architecture. In fact, GitHub remains one of the biggest advocates for this technology, encouraging its developers to contribute to Rails development

We have removed nearly all of our Rails patches. Since we are running on the latest version of Rails, instead of patching Rails and waiting for a change, developers can suggest the patch to Rails itself.

So what does all this mean for RoR? It would be easy to say this framework is simply falling out of favor and sooner or later will be gone, but it is never that easy in the tech world. 

Rails' position is too well-established in the enterprise world, and the community is too vibrant to let it die. Moreover, the framework itself has much to offer, even compared with the 'new kids on the block.' After all, 2024, Ruby on Rails is used by 5.7% of all the websites whose server-side programming language is known.

Key principles of Ruby on Rails

Model-View-Controller (MVC)

The Model-View-Controller (MVC) framework is a design pattern that separates an application into three interconnected components: the Model, the View, and the Controller.

  • The Model represents the data and the rules that govern access to and updates of this data. In Rails, each model corresponds to a table in the database and is represented as a class.

  • The View is responsible for rendering the user interface, typically in HTML. It presents the information from the model in a format suitable for interaction.

  • The Controller acts as an intermediary between the Model and the View. It handles user input and updates the model, which in turn updates the view.

The MVC architecture in Rails enhances the extensibility of web applications, making it easier to manage and build applications, even complex ones. It also promotes code reusability and a clear definition of interfaces.

Convention over Configuration

Convention over configuration (CoC) is a software design paradigm that minimizes the number of decisions a programmer must make by providing default settings. 

In Rails, CoC can be seen in many areas of the MVC architecture. For example, model class names are based on database table names, class attributes are based on database column names, and view file and template names are based on controller action names.

Convention over Configuration lowers the entry barrier for beginners because they can start coding without having to set up complicated configurations, instead using simple conventions of Rails. It allows developers to focus on delivering functionality rather than dealing with low-level infrastructure.

Don't repeat yourself (DRY)

Don't Repeat Yourself (DRY) is a software development principle intended to reduce the repetition of information or code. It states that each piece of knowledge must have a single, unambiguous and reliable representation in the system

If the DRY principle is successfully applied, modifying any single element of the system does not require changing other, logically unrelated elements. In addition, all elements that are logically related change predictably and uniformly and are therefore synchronized

The DRY principle contributes to Rails performance by preventing errors and speeding up development. This makes the code cleaner and easier to maintain.

Features and Advantages of Ruby on Rails

Simplified and Readable Syntax

Ruby on Rails (RoR) is known for its friendly, English-like syntax, which makes it easier for developers to understand and read the code.

Let's take a look as the code example:

This simplicity and elegance of syntax make Ruby easier to learn and work with, allowing developers to significantly cut development time and enhance collaboration among team members.

Open-source nature of Ruby

Ruby on Rails is an open-source framework, which means it is free to use and distribute. No licensing fees involved means it can be cost-effective solutions. Of course, using open-source typically requires significant in-house resources but a vibrant community of developers who contribute to Rails development and maintenance ease thay out. There are plenty of resources, tutorials, and libraries to accelerate development and solve common technical problems. 

As of the latest data, the approximate number of Ruby developers is 1.8 million, and more than 4,000 active Rails contributors on GitHub, who take care of improving the existing functionalities, adding new features, updating the code, and fixing bugs.

Rails also has many community forums, including GitHub, Slack, and Stack Overflow. Their Slack community has over 17,000 members and 27 channels from all over the world.

Access to libraries and tools without additional costs

RoR ecosystem includes a rich set of libraries and tools that developers can use to enhance their applications. Some of these include Devise for authentication, RSpec for testing, FactoryBot for fixture replacement, Brakeman for security analysis, Active Record for Object-Relational Mapping (ORM), Capybara for acceptance testing, Sidekiq for background processing, Puma as a concurrent server, RuboCop for static code analysis, and Rails Admin for data management.

There is also RubyGems, a package manager that simplifies the process of installing, updating, and managing dependencies for libraries, also known as "gems". These gems are code packages designed to enhance the functionality of Ruby applications, and the RubyGems repository hosts over 170,000 libraries, making it easy for developers to find and install the gems they need.

Test Title

test BaseText to verify if the typeof will be string

Kaja Grzybowska avatar
Kaja Grzybowska