Node - 21st Century Concurrency

11 Nov 2009 | By Alex Young | Tags concurrency networking server nodejs

Node is event-based IO for V8 JavaScript. It provides an alternative approach for building non-blocking scalable programs using a model inspired by EventMachine and Twisted.

Here’s an example taken from nodejs.org:

var sys = require('sys'), 
   http = require('http');

http.createServer(function (req, res) {
  setTimeout(function () {
    res.sendHeader(200, {'Content-Type': 'text/plain'});
    res.sendBody('Hello World');
    res.finish();
  }, 2000);
}).listen(8000);

sys.puts('Server running at http://127.0.0.1:8000/');

Node’s features include events, timers, child processes, POSIX, TCP, modules (from CommonJS) and there’s even a REPL for experimenting. For more information, visit:

blog comments powered by Disqus