Hello!
I am trying to do a sort of indirect comparison between Rails and Node.js. The very main reason of being indirect, is that Rails is a Framework, while Node.js is an implementation of a programming language.
If it were be to put in a simple phrase, Rails is resourceful and Node.js is fast.
Lets elaborate some..
Rails
Is the most complete open-source framework available (that I know of)! Big companies use it. It can do lots of stuff well, in an organized manner; this meaning, Rails is more than just MVC, it has a full stack of features well-integrated, at the same time being very modular. Some of the features included out of the box:
- Database adapter for the majority of them, supporting plug your own.
- Database migrations, so multiple dev can sync and experiment with their DB.
- Powerful engines for Views, Controllers and Models.
- Support to code generator.
- Has structure to all sorts of tests and friendly to TDD.
- Really awesome documentation.
- Model has all kinds of hooks, validations and associations.
- Controller has support to handle XML/JSON in the same action that serves HTML.
- Gems that integrate, for instance, Memcached, MongoDB, Auth and lots more.
Node.js
Two things make this language extremely suitable for web:
Its engine, V8 is very fast! In a very loose average, 8 times faster than Python (or even up to 200 at peak). Python already outperforms Ruby
Second point; and this argument is separated from the above, is that it async-driven. As in the case, requests can be performed in parallel, without any blocking I/O. A single server can handle a lot.
So, it is a very new sort of backend language, but huge players, besides Joyent, who invented it, are adopting it, including LearnBoost and LinkedIn, which has an awesome article about using. The language, and it main web framework, Express, deserve a list of features (you can check more info in the references below).
- It´s web server is able to handle a HUGE number of connections out of the box
- Various libraries can be run on browser, the same as in the server
- Very friendly to Websockets (real-time web apps)
- Lots of libraries are being ported to it from other langs.
- Express, inspired in ruby´s Sinatra; is very light on memory but also very powerful
Summarizing, When to use each?
Rails really shines when..
- The database is complex in terms of associations.
- Business rules are complex, and validation is needed.
- When the number of requests isn´t the a decisive factor.
- Administrative interfaces.
- Many developers in parallel each using his own database
- The database to be used is undefined, or may vary.
- APIs
- Real-time web/mobile apps.
- Application that should scale to lots of concurrent requests.
- Little memory footprint
This being said, there is no reason at all, a web-site or service can´t easily integrate both.
– I’d appreciate if you could leave a comment, either to talk about your case, or add up.
References
UPDATE: http://www.mikealrogers.com/posts/a-new-direction-for-web-applications-.html
http://guides.rubyonrails.org/
http://blog.heroku.com/archives/2011/6/22/the_new_heroku_2_node_js_new_http_routing_capabilities/
http://akitaonrails.com/2011/04/16/twitter-muda-de-ruby-para-java-ruby-e-3x-mais-lento-que-java
http://venturebeat.com/2011/08/16/linkedin-node/
http://blog.bossylobster.com/2011/08/lesson-v8-can-teach-python-and-other.html
http://www.readwriteweb.com/hack/2011/01/how-3-companies-are-using-node.php
http://twitter.com/#!/FlockonUS/status/104655096956190720
https://github.com/LearnBoost/cluster
Tags: comparison, node.js, performance, rails
Conclusion is very clear .
Thanks for commenting!
I guess the conclusion greatly varies from the use case, what would be yours?
Node, I choose you!
Teh internetz use Thousands of Requests!
Node reply in 1 second!
It’s super effective!
That’s the point, right?