NodeJS v/s Rails

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.

NodeJS is a runtime environment for running JavaScript server while rails is a framework for Ruby.

Pros of NodeJS

NodeJS is fast

  • Learning Curve

The code is written in JavaScript so anyone with prior frontend development experience can easily learn NodeJS. It is also easier for those having background in C++ or JAVA.

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

  • Multi-threaded

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.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s