There are thousands of articles on the internet discussing the pros and cons of NodeJS and Rails. This is one of such article. Let’s get something clear.
Pros of NodeJS
NodeJS is fast
- Learning Curve
Rails is more similar to Python with no brackets or semicolons.
- Flexible Project Structure
Rails require a definite file structure. It has an architecture that looks for a file in specific locations only. Move any item from one directory to another and Rails create havoc.
NodeJS is very flexible. Put your code anywhere, change it’s directory later and it’s fine.
- No strict filenames
Change the name of files in Rails and the server will crash. Suppose there is a controller in your project with the name of controller file as user_controller.rb. Now, if you change the filename Rails will crash. This is because it implicitly imports files by looking up the filenames based on its internal logic.
NodeJS has no such limitations. You can name your file user_controller.js or UserController.js or anything else. You just require the files whenever you need to use them.
Pros of Rails
Rails is multi-threaded which is better for CPU intensive operations. NodeJS in comparison is single threaded and was designed for heavy I/O bound applications.
- No callbacks
In Ruby, all the instructions are executed sequentially making Ruby a good scripting language while NodeJS functions asynchronously.
- Code Maintenance
Ruby on Rails follows coding conventions which make them easy to pass work from one programmer to another. Since NodeJS allows flexible file structure it can create problems while handling code from one developer to another.
There is a tradeoff between ease of code and performance of the server.
Rails should be used for CPU intensive operations while NodeJS should be used for I/O intensive operations.