Node.Js VS Ruby on Rails

I am going to make a comparison between Node.js and Ruby on Rails for web development. I will talk about both the advantages and disadvantages of the two server-side technologies & web stacks.

What are the Similarities?

  • Popular server-side technologies
  • High Performance
  • Strong Community
  • Similar MVC based structure (Ruby on rails is hard MVC, you have a folder for your models, your controllers, and your view. Compare to node express is more flexible in its structure, Rails you can just take certain aspects of MVC
  • Rapid Development and prototyping ( Rails has a folding feature and express has generators and command-line tools)

Rails Advantages

  • Consistent Structure, like I said earlier, rails has a very strong MVC (Model-View-Controller) structure, most rails application are going to look similar in terms of the core file and folders, you have a strong foundation and then you build that with gems and custom packages and libraries.
  • Very Opinionated, meaning it makes you adhere to its way of doing things. Rails is going to assume that you’re going to write code in a certain way, it’s a little restrictive but makes for easier and much cleaner code, this also makes it harder to have errors and issues.
  • Database Migrations rails have really good database migration functionality, they allow us to create and edit tables and columns in our database without having to manually go in and add/change things. It also gives you a nice little log or path that you can follow to see exactly what’s been done to the structure of your database. (Node there are some packages or modules for migrations such as DB migrate which can work really well but it’s not in-depth and as easy to use as the rails core migration system)
  • Speed of development when is come to prototyping and rapid development, rails is super fast with some basic configuration and a couple of scaffolding commands and you have yourself a full functioning CRUD application (NodeJS Express is fairly good with fast development if you use third-party tools and modules but rails has all that stuff right out of the box)
  • Ruby is a great language that is very clean, a lot of it actually looks like plain English, you can do procedural code functional but for the most part, it’s object-oriented, which means everything can be looked at as an object.
  • Ruby Gems is a package manager for Ruby on Rails, it used to extend the core functionality of the framework, it’s similar to NPM for NodeJS. All Rails applications have a gem file where you can specify your gem and you can run gem install them similar to NPM install with NodeJS.
  • Mature & Respected Community. Ruby on rails has a lot of good resources about core.

Rails Disadvantages

  • Performance is relatively slow, compared to Node.js Express which is really fast, but it’s also really lightweight. Rails has a lot of features in it, like core it makes sense that it doesn’t perform as well as some of the lighter frameworks, you also have to factor in the gem and file dependencies of an application.
  • Too Simple, I mean when the new developer decides to learn rails and they set up a new application there’s so much automation and scaffolding that the developer doesn’t really learn very much about the Ruby language or syntax and the structure of their application. Rails are more difficult in big projects than small applications and can have some issues with scaling as well. But it is great for the developer to have a good understanding of Ruby on Rails very well because of its rapid development.
  • Lack of documentation, they have good documents about core, but if you want to learn more about gems it is hard to find a good document.

Node.js Advantages

  • Extremely popular, there’s a flourishing open-source community around Node and the express framework, very well developed modules on NPM.
  • High performance, when it comes to speed/performance Node.js is way quicker than Rails. Node.js runs on the Google V8 Javascript engine which is lightning fast, Node is used to build real-time web applications.
  • Asynchronous I/O, when a program sends a request to the server it doesn’t have to wait for the reply, it can continue to execute (non-blocking I/O)
  • Very Scalable, being on a single thread example, like apache has to handle a lot of requests to a set of threads which gives it much more overhead and it slows things down. Node also works very well with NoSQL databases like MongoDB. More scalable than traditional databases like MySQL.
  • Javascript Front & Back End, easy to use the same language with both front and back and also Javascript works well with JSON API which is very popular.
  • Flexible file structure lets you structure your applications however you want, you can put everything in the Js file or you can have a more traditional MVC structure. Both have pros and cons but if you know what you are doing as a software developer flexibility is a good thing.
  • NPM & Modules, the difference between Ruby gem and NPM is how dependencies are managed. With Ruby dependencies are installed globally, so we have to use the bundler, but NPM will take care of all that for you. Example: modules they get put into the node modules folder for you, and also can have their own node modules folder.
  • Most developers learn Node.js very fast because they already know the core language.

Node.js Disadvantageous

  • Not good for CPU intensive tasks, whenever it does something that takes a while, such as a CPU operation, it’ll queue all the incoming requests because it runs on a single thread. Examples, like 3D rendering, video encoding, scientific modeling, sorting.
  • Inconsistency, the API changes at frequent intervals and it sometimes is not very backward compatible. The structure of the Express application, in general, is very flexible compared to Rails is very strict which means that it’s harder to write bad code.

Conclusion

Both of them are fantastic technologies, If I have to choose I will go with Node.js Express, because it is more popular, highly scalable, and performs much better. But everything should always be evaluated on a case-by-case basis rather than just saying one is better than the other in all situations.

--

--

--

Software Development with a background designer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Don’t Dress to Impress in the Winter

Literals and Type Inference in Swift

Lessons from my first developer role

How to Let Others View Your Calendar Using iCalendar Feeds

SSIS Azure Blob Destination

Setup custom fast super-lightweight CNCF certified multi-node k8s cluster in minutes anywhere

Journey starts here…

Redis — What and Why?

Redis

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alice Richardson

Alice Richardson

Software Development with a background designer.

More from Medium

Rails API

Writing, Accessing, and Modifying Nested APIs with Ruby & Sinatra

Creating a Rails plant tips CMS site

Auth on rails with bcrypt