Node.js and Ruby on Rails are two popular solutions used in web development. Both loved for their simplicity, speed of development, and easy code maintenance, they are often compared and seem to be good alternatives to Python, Java, PHP or .NET.
When Ruby on Rails was first introduced, it was quickly appreciated for its simple and readable, English-like syntax. However, RoR’s popularity has been slowly declining over the past few years. And even though the decline of RoR is rather slow, we can notice that every time it tries to recover after its minor declines, it rarely gets back to the previous level.
Node.js, on the other hand, seems to be just at its best – and it’s higher than Ruby on Rails has ever been!
Companies are switching to Node
Ruby on Rails was originally used for building famous software products, such as Basecamp, Twitter, Netflix, Slideshare, Dribble, Kickstarter, Airbnb, Github, or Groupon.
Many of them, however, are now gradually migrating to Node.js: Twitter, Groupon, Netflix, just to mention a few.
Read about 13 best Node.js safety practices
Why are these companies migrating to Node.js? Is it simply better than Ruby on Rails? And does it actually indicate that Node.js development is now a better choice than Ruby on Rails development? Let’s analyze the advantages and disadvantages of both!
Node.js pros and cons
|Node.js pros||Node.js cons|
The same language on client and server-side makes Node.js applications faster than the ones that utilize different languages. Also, writing web applications in Node.js, using JS from back- to front-end is an optimization factor that may shorten time-to-market and make the future maintenance easier.
Node.js is based on one of the fastest engines – Google’s V8. The speed of code execution is also enhanced by runtime environment as it supports the non-blocking I/O operations. Node.js is able to demonstrate really high runtime speed giving much faster coding experiences to the programmers. Thanks to that, Node.js apps are faster to develop and they serve the same amount of traffic with less hardware.
Node.js is lightweight both for in-memory usage and data-dense real-time web applications that work on multiple devices. As it requires a relatively small amount of computing resources, it is not only fast (as mentioned above), but also more accessible for users.
There are three reasons that stand behind Node’s scalability: it is one of the technologies natively handled by AWS, it can be easily broken down into microservices, and it has an event-based model.
Scalability makes Node a good choice for applications that are expected to quickly grow the number of users. It’s not a coincidence that companies such as LinkedIn, Netflix, or Twitter are switching to Node.js.
Read also: Node.js vs Python
Easy working with large files
Thanks to Node’s stream modules, it is easy to handle large files. Streams are basically the collection of data – just like arrays or strings. Unlike them, streams don’t need to be available all at once. Thanks to that, they don’t have to “fit” in the memory limits – and that’s like a holy grail for the challenges of handling large amounts of data!
It handles the requests simultaneously
The ability to handle the requests simultaneously makes Node a perfect environment for real-time web apps such as chats, games or collaboration tools. With Node.js, multiple users can be editing the same file, moving tasks between the boards, commenting, adding media files – all at the same time.
It is growing really fast!
A new version is released every 6 months, there is a great choice of open-source scripts, libraries, and applications supporting Node.js, and there is a wide range of hosting options and built-in server support. Also, the community behind Node.js is large and getting bigger each day. The bigger the community gets, the easier it is to get support.
Read also: Using Node.js for back-end development
Node.js is a relatively new technology. Even though its core is stable, some packages in the npm registry have not been properly documented yet – which makes them more difficult to use.
Even though it is able to handle the requests simultaneously, we need to remember that there is no multithreading. If a real-time Node.js application is not implemented correctly, the callbacks may slow it down. When implemented correctly, however, it’s not a con anymore.
Is Node.js unstable?
Node.js has been criticized for changing API at frequent intervals. Is it a serious issue? Well, when the API changes, developers need to make changes to the existing code base to make it compatible with the latest version of the Node.js API. The things are changing over the new versions of Node, so it may not be the reason to discredit it but it’s worth to keep such issues in mind when building a Node.js app.
Pros and cons of Ruby on Rails
|Ruby on Rails pros||Ruby on Rails cons|
Pros of Ruby on Rails
Speed of development
The Convention Over Configuration approach allows developers to start working on the actual products as soon as possible – with as little time spent on configuring the environment as possible. This is not only convenient for the developers but it also contributes directly to shorter time-to-market. That’s right! Ruby on Rails comes in handy if you want to build your app very fast and verify your startup ideas on the market. Once there are users, you can collect feedback, watch their behavior, verify your early assumptions and set the right path for further development.
Simple, English-like Ruby on Rails syntax
It is often said that if you speak English, you are able to understand Ruby. While it is not literally the truth (sorry, some level of understanding of the whole concept of programming will be useful anyway), it is true that Ruby’s “natural, English-like” syntax is easy to read and easy to write.
Rails is an open-source web application framework supported by an active and supportive community of developers. Not only are they able to help each other when they face some challenges, but they also ensure that the Rails framework is regularly updated, bugs are fixed, and security issues are up-to-date with the industry standards.
It’s an open-source solution with a rich set of gems
In Ruby on Rails, Gems are the libraries with specific functionalities that allow its users to extend and customize the applications. As everyone can create one, there are thousands of them available, serving different purposes – from authentication and authorization to payments processing and testing.
Cons of Ruby on Rails
Let’s face the truth – Ruby on Rails is not a speed demon. As it’s not really an issue when you release the first version of your product, the problem will grow proportionally to your users’ database.
RoR’s defenders claim that in most cases, the performance issues of RoR applications depend on the server or database architecture and… the skills of your engineering team – and not on Ruby on Rails itself. Nonetheless, if you don’t work with true and experienced RoR masters in your team, performance issues may arise at some point.
When you search for some information about RoR applications scalability, you will quickly learn the story of Twitter. Initially built with Ruby on Rails, then switching to Scala in order to handle their growing number of user requests. LinkedIn went through a similar transition switching their back-end mobile infrastructure (built on Ruby on Rails) to Node.js. On the other hand, there are apps such as Shopify, Github or Couchsurfing that scaled quite well.
To be fair, there are solutions to make a RoR application scalable. First and foremost, it can’t be a monolith. Microservices scale better, regardless of the technology. Then, there is a set of good practices (you can read about them here) but applying them usually requires a good set of skills and sometimes it’s simply not worth it. Ruby on Rails may be a perfect pick to build your Proof-of-Concept as fast as possible, but it’s much trickier in case of larger projects.
Slow runtime speed
This one is related both to RoR applications’ performance and scalability. Ruby on Rails it’s slow compared to its peer platforms like Node.js or GoLang. It won’t be a problem if you have a small app but it may affect its scalability in the future.
Lack of flexibility
Ruby on Rails is considered a very opinionated framework, meaning that it only lets you create your app in a specific way – the one that Rails “wants” you to. Convention over configuration, right? There is a lot of default, set objects what may not leave enough room for developers’ creativity. While this approach brings some benefits (especially when you build an app with some standard functionalities), it may be a pain while developing some more unconventional apps, forcing you to to choose between the development time or app’s uniqueness.
Open-source solution with a (too) rich set of gems
As said before, Ruby on Rails is an open-source framework where everyone can create a library (Gem) serving various purposes. So if you have developed some nice feature and you feel it’s a great thing that is not provided in any library (or it’s better than the one from an existing library), you are free to create your own Gem. Once you push it to the public repository, it will be available for all Ruby on Rails users.
As you can imagine, there are thousands of gems available! But only the popular ones have proper documentation, and only the popular ones are developed. Many of those available in the RubyGems repository were abandoned and they are no longer supported.
Which is better: Ruby on Rails or Node.js?
Unfortunately, there is no clear winner in this battle. If we compare node.js vs rails, each of them will be the winner… in certain categories.
If you are focused on building your application as fast as possible, you may consider choosing Ruby on Rails. It will be a good choice if your project has tight deadlines and budget requirements. Keep in mind, though, that this decision may have some negative impacts when your app grows – Ruby on Rails is often criticized for performance and scalability issues. Also, in the longer run, it may be quite expensive to hire a good RoR developer.
If you measure high and want your product to scale, or if you build an innovative web application development service that requires total control over the framework architecture, modules, database integrations, and server deployment – then Node.js is the right choice for you. It is fast, lightweight, and scalable. Combined with the way it handles large files and multiple simultaneous requests, it’s a particularly good choice for all real-time applications, chats, streaming applications, or collaboration tools.
The truth is, the choice of the perfect technology for your project should always start with the assessment of your challenges and needs. Once you realize what they are, it is much easier to evaluate which technology will serve your application better.
Learn more about the types of applications you can build with Node.JS