Node.js - lightweight and efficient

Using Node.js you can write a web server in as little as six lines of code.
Here is a variation for the sample from the Node.js (Node.js Synopsis)
//Imports the http library
var = require(http);
http.createServer(function(request, response){
    response.writeHead(200,{'Content-Type':'text/plain'});
    response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

I was asking myself why would i want a server side javascript (which is the whole idea of Node.js) ?
Besides that it uses a non-blocking I/O model (this means that other processing can continue if it does not depend fro an I/O to complete, kind of like an asynchronous call to perform the I/O) .
One use case that i can think of is that  I can wrap other services (e.g. other source of data like json/xml)  specially ones that are exposed as web service APIs (e.g. Google APIs).

Comments

Popular posts from this blog

OAuth 1.0a Request Signing and Verification - HMAC-SHA1 - HMAC-SHA256

Spark DataFrame - Array[ByteBuffer] - IllegalAurmentException

Gensim Doc2Vec on Spark - a quest to get the right Vector