What is NodeJS?

I have been researching new open source offerings and came across a platform called NodeJS; which at first glance seems to be simply a JavaScript command line interpreter, but in reality is much more. I have heard things about NodeJS before but have never had the chance to take a look at it. Node is built on top of Google’s V8 JavaScript engine which powers JavaScript processing in the Google Chrome browser. To date V8 is one of the fastest JS engines around.

Node is also great for those familiar with JavaScript but haven’t ever had the chance to delve into more complex server side development. Yet Node is far more than a simple JavaScript CLI because it ships with a large variety of features like an HTTP library and a TCP library. Node also seems to have the ability to simplify threading (which can be a daunting task even for experienced developers) by offering functions like setTimeout and setInterval, events can be handled with ease.

The platform advertises itself as non-blocking, meaning that when a program is waiting for something to do it remains idle, rather than sleeping. This allows more efficient processing of concurrent real time events. The video below also suggests that Node would be an excellent candidate for a streaming server because of the way it handles concurrency.

Node is also incredibly simple to use. Those familiar with Python know how typing “python” at the command line brings up a “python” command prompt where you can execute code directly from the terminal and if you pass in a file after python, that file will be executed. Well, NodeJS works the same way.

Here’s a simple web server taken from the NodeJS homepage:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '');
console.log('Server running at');

Right now, those involved with the development recommend building from source due to the rapid changes that are being made to the code. It is as simple as a configure, make, install. Additionally, it seems NodeJS is best experienced with Unix/Linux based operating systems but better Windows support is in the works.

Check out this video where Ryan Dahl introduces node during a San Francisco PHP Users Meet up. It covers many of the features Node has to offer and is pretty entertaining as well.

This seems to be pretty cool and most likely will become very popular, especially with cloud services like Windows Azure and Amazon EC2. Check it out and stay ahead of the learning curve.

%d bloggers like this: