Node JS

Node JS has generated a lot of interest lately so I’ve had a bit of a play and so far I like what I see. Most of the publicity about Node seems to be to do with performance; this is because it doesn’t use the traditional model of spawning one thread per client connection. That in itself is great but not of direct interest to me. However, this model allows you to perform asynchronous actions without worrying about the event loop and threading. For example, the following HTTP server code snippet sends the response to the client from within a nested asynchronous callback function:

var http = require('http');
http.createServer(function (request, response) {
    doSomethingAsynchronous(function () {
        doSomethingElseAsynchronus(function () {
            response.writeHead(200, { "Content-Type": "text/plain" });
            response.end("Hello World\n");
console.log("Server running at http://localhost:8124/");

This event loop model, plus the ability to use the same programming language on the client and server (although server-side JavaScript has been around for a while) is definitely something that has caught my attention.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s