Tuesday, May 03, 2011

The Magic of Node.js


A while ago, Google came out with a high-performance JavaScript engine called V8. This is what powers the Chrome browser.

Now along comes an Open Source project called Node.js (or simply Node) that wraps V8 with networking capabilities, enabling some very cool JavaScript-based servers (HTTP or TCP) to be written with just a few lines of code. Servers written for Node are non-blocking and multi-tasking without having to be multi-threaded (the demo below explains more), which also makes them very fast and scalable. This is server-side JavaScript at its best.

This hour-long demo is worth watching. I haven't been so amazed since I saw Scott Davis demonstrate Groovy at JavaOne 2009.

The only downside (not to me, though ;-) is that Node currently only works on Unix-like systems (Linux, Mac) and not yet on Windows. You also have to compile from source (no binaries yet), which is not a big deal because you only have to type "./configure". "make" and "sudo make install" one after the other in the main directory once you've unzipped the tar.gz file using "tar zxvf node-VERSION.tar.gz".

Refcards has a reference card for Node.js.

There are some great possibilities here, such as when you combine this with E4X.

3 comments:

David Urquhart said...

Do you think it's like Napster for program execution? ie peer to peer but not just for data sharing.
I'm imagining a company CRM system built atop Node - active users might have their service provided by colleagues whose browsers are inactive.
Nodes might self arrange to perform roles and marshal to ensure there is the optimal number of app servers, data servers and overseers.
This could revise Amazons revenue projection?

prasadgc said...

David,

When you lower the barriers sufficiently, who knows what ideas will become feasible? Node.js is still in its infancy and not many have heard of it even now. I think we'll see some very interesting applications being enabled by this.

Regards,
Ganesh

a user said...

hey Ganesh ....
Node is available for Windows, you can either get pre-compiled binaries (worst option IMHO) or compile with cygwin, i installed loads of modules via npm and all the stuff i do on my ubuntu box or mac book pro also works on my windows 7 laptop ... just follow the node installation guide/help on github :) happy coding :P