Node.js Evented I/O

This is one of the most interesting things i've seen this month.

Node.js is an ambitious project, which uses javascript to open up a web server that has a different behaviour compared to common web servers.

It's built on javascript event-oriented programming, so it's easy to use. (a lot easier than other similiar library like Ruby's Event Machine or Python's Twisted, because developers are used to deal with javascript events).

The standard servers has limited thread and processes that can respond to a request, if enough long-running operations are requested the server can easly become unresponsive, this is a common problem.

With Node the request doesn't lock the process, it just raises an event when the operation is complete.

The key is that "there are no locks. Almost no function in Node directly performs I/O, so the process never blocks".

Example of a web server that respond "Hello World" to every request:

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

To run the server, just call the "Node" command with the javascript file (that contains your code) as argument, like so:

% node example.js
Server running at http://127.0.0.1:8124/

Web functionalities such as File Uploads or Web Chat could take great advantages of this technology.

The future will be brighter for real time applications developers.