(update) Take this post as a naive overview, it may not reflect the most accurate reality
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 a runtime with custom libraries.
If it were be to put in a simple phrase, Rails is resourceful and Node.js is light and fast.
Lets elaborate some more..
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.
Two things make this platform 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 (ref. bottom)
Second point; and this argument is separated from the above, is that it async-driven (is built around reactor pattern). As in the case, requests can be performed in parallel, without any blocking I/O. A single server can handle a lot. (update) And with >0.6.0 Cluster API, it can scale to use all of available CPU cores.
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’s 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.
- The app structure is well defined.
- 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 keep the DB up-to-date with migrations
- The database to be used is undefined, or may vary.
- 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.