As new/experienced developers research which language they should learn to expand their skill set, Ruby on Rails(RoR) has always been a question mark. Many consider the framework to be old, out-dated. On the other hand, many consider it powerful as Rails can be used to build apps quickly and easily. So which one is it? Is it worth it to learn Rails in 2021?
When picking a new language/framework to learn, it is important to determine what we want to do with it and how it’s going to work in the back-end. Will it be an e-commerce app? Rails will be very practical to use. Will it be a very interactive app that allows users to create/cancel appointments? Maybe react will be a better tool. It really depends on how you want to set up your app/database structure and how fast you want to get to a working product.
First released in 2004, Rails is a server-side web application written in Ruby. It has a Model-View-Controller (MVC) framework which provides structures for web pages, a web service, and a database. With Rails, we can build from 0 to a product very quickly and allows us to be productive and efficient. It is also an ‘opinionated’ software. What does that mean? It means that it makes the assumption that there are “best” ways to perform certain things, and it’s designed to encourage that way — and in some cases to discourage alternatives. This means that it feels not as flexible, compared to other languages/frameworks.
There are 2 major philosophies for Rails:
- Don’t Repeat Yourself: DRY is a principle of the software development process that is pretty common across multiple languages. We should not be writing the same information over and over again, and this would make our code more maintainable, more extensible, and less buggy.
- Convention Over Configuration: Rails has opinions about the best way to do many things in a web application, and defaults to this set of conventions, rather than require that you specify minutiae through endless configuration files.
Developer Salary: Indeed
The above chart is an average developer’s salary in the US in 2018. The salary gives us a better insight into the supply/demand side of things when it comes to recruiting developers with a Rails background.
Programming Language Popularity Rankings
Rails In the Real World
Netflix, Airbnb, Microsoft are just a few examples of companies that use rails. So why do these companies use Rails today? What are the benefits?
- Open source: Rails is a free resource and has rich libraries(gems) that can be used to develop our app.
- Secured: Rails have features to protect application makers from common issues like CSRF, Script Injection, SQL Injection, and the like.
- Large Community of Professional: Rails is continuously evolving. A large number of developers are choosing Rails as their programming language. A lot of developers prefer to Q&A platforms such as Dev & Stack Overflow to discuss issues and problems regularly and share new tricks/articles/ideas. This is critical, as support, improvements, and contributions are VERY important to keep the framework up-to-date with today’s technology and keep it relevant. Once it becomes outdated, it will quickly lose developers’ support and commitment, and will eventually be replaced by other frameworks.
- Collection of Gems: Rails provide a huge collection of “Gems”, gems is a set of instructions or software packages that runs on ruby app or library. Gems are used to save time and improve the performance of the application. It also speeds up the development process.
- Time Efficiency: Using Rails would be the best choice when it comes to fast web development, whether it’s a startup or an enterprise application. For projects that have tight deadlines, Rails will resolve your time-related issues and help you to get our web application within time.
- Shorter Code: With Rails, we don’t have to write out all the SQL commands as we do in Node.js. For example with Ruby, we can use something like this to fetch data from our database (assuming we have set up the controllers and views):
@category = Category.find(params[:id])
whereas in Node.js, we need to import express, use a router to route it, and query it using specific SQL commands,
SELECT “categories”.* FROM “categories” WHERE “categories”.”id” = $1 LIMIT 1 [[“id”, 3]]
So there are a lot more code involved when using express, and modules that need to be installed in order for us to fetch data from our database. We are able to replace 30 > lines of code into a simple one-liner.
But what about the negatives? What would prevent someone from using Rails? Why has there been a shift to other languages, rather than taking full advantage of Ruby magic?
- Performance: Truth be told, Rails is not the fastest horse in the game. If we need a really fast performing app, Rails is not the way to go. We should keep in mind that this is an edge case, and in most projects, we really don’t need that much speed, especially if we’re building an MVP.
- Scaling: In 2008, twitter decided to move away from Rails and started to use Scala, which is based on Java. This caused a lot of “Rails is dead” posts to surface. Is it practical to scale with Rails? The answer is yes, we definitely can. We can upgrade the server Rails is on or divide the work to multiple servers and tools. Is it worth it? Well, it really depends on our application. but this would cost a lot more to run the server infrastructure, compared to using NodeJS.
- Not really flexible: We previously mentioned that Rails was ‘opinionated’. While this feature can be very convenient at times, it may be a pain while developing an unconventional application. There is a lot of default, set objects that would limit developers’ creativity, and they’d have to choose between sacrificing development time or creativity.
- Rails can be an overkill for some apps: Not all apps need to use Rails. It can be a bit too much and there may already be some existing tools that do exactly what our client has requested. You wouldn’t want to build an ‘about me’ app using Rails, for example.
- AI: Machine Learning(ML) and AI have been the hottest keywords over the last few years. A lot of apps these days utilize AL/ML to provide meaningful data to users and provide them with a better experience. Languages such as Python and Java can be utilized for Al/ML and is certainly much faster than Ruby. Unfortunately, Rails does not support this kind of technology, mainly because of the lack of libraries.
A lot of big companies are still using Rails today and being knowledgable with the framework will be a great benefit to have. As we have seen, it has an established job market and is in high demand. While it’s not as hot or flexible as other languages, the future of Rails is still looking great.
The stats above are truly astonishing. It proves that Rails can be used to process millions of orders a day, and do it well. And as further developments are underway for Ruby, it will only get better from here.
If we don’t see the benefits of using Rails or are simply developers who are not familiar with Ruby, it could save a big amount of time to go ahead and use other frameworks. However, RoR has a relatively low learning curve and has a lot of useful gems that make using the framework very attractive. For the last 18 years, Rails has provided a mature, reliable method to allow millions of apps to be deployed. It will continue to provide developers quick, efficient tools to launch secure, effective apps.
However, It is important to realize that language is not all that important. What is important is the process, and understanding of how the new languages/frameworks could be utilized to develop our app effectively. At the end of the day, we would be exposed to languages that we are not familiar with. Having the ability to pick up new languages efficiently and quickly should be the goal for every new/experienced developer.