Convince the Boss
List of reason to use node:
- Speed. V8 is fast. It's faster then python, it's faster then php.
- Evented IO. IO done properly. No messing about with threads, everything works nice and easily.
- Low level web server. A good control over the abstraction in a dynamic language.
- JavaScript. A great language with a lot of developers experience in writing asynchronous code. Development is fast and maintenance is lovely as everything can be done in one language (clientside, server-side, database access).
Libraries and tools that can be used with node.js:
- express.js : MVC Web framework. Very lightweight. Gives you routing and views. Builds ontop of connect.js. Out of the box flexible control of views and routes with multiple css and templating engines supported. As with node.js itself it's simplistic and gives you fine grained control of your web server. Personally I find the balance between control and abstraction about right.
- socket.io : The de-facto websocket abstraction. Lot's of graceful degradation support build in so browsers without websocket use comet techniques or a flash bridge. Allows you to talk between client and server in a no-hassle, easy and realtime manner.
- now.js : Builds on top of socket.io and gives you a synchronized name space across client and server. Allows you to trivially call server methods from the client or vice versa.
All of these libraries are based on the fact that node.js allows you to handle everything on a low level manner and that communication with the client is smooth and streamlined because you use the same language on either end.
The selling point for me is that I have the same MVC library backbone.js on the client and the server. All my model code is re-used. The models on the client and the server are synchronized trivially over now.js.
My database access is driven by cradle (or mongoose) which is all written in JavaScript. Actually my MVC ties directly into the database and seamlessly saves my models. The models define useful methods like save
and fetch
to do persistent database storage. I don't manually touch the database because my MVC allows me to plug-in in a database driver to do this for me.
The rendering of my templates is done with EJS, my views are shared among the client and the server. There is simply a large amount of code-reuse and my entire web development is done in JavaScript which means I don't have to switch my coding paradigm or style.
Nor do I have trouble deciding how I should handle the grey area between what lives on the server and what lives on the client because that grey area has been completely smoothed over and the client and server integrate seamlessly.
If you're going to write a complex dynamic ajax web application then node.js is a perfect candidate. If you're going to have a static website then node.js is a perfect candidate (You set it up in 20 minutes).
If you're going to write a server heavy website with little client side functionality and postbacks then maybe you're better off using php or ASP.NET. But if you're doing that you should looking into more dynamic client side functionality and using ajax.