Node.JS, Hello World!

I'm completely new in Node.JS, just read about it for the first time. Based on  wikipedia "Node.js is a server-side software system designed for writing scalable Internet applications, notably web servers. Programs are written on the server side in JavaScript, using event-driven, asynchronous I/O to minimize overhead and maximize scalability."

Node.js platform was created by Ryan Dahl starting in 2009. You can develop a real-time, two-way connection (client and server side) web-based application by NodeJS. It operates on a single thread and allows for thousands of concurrent connections so seems to be suitable for particular needs. NodeJs has a built-in HTTP server library and it enable to run a web server solely and it also uses event-driven and non-blocking I/O (unlike traditional web development tools and mechanisms) model which makes it suitable for real-time applications. As I mentioned NodeJS does not use traditional request/response (a thread for each of them), it just uses one thread by default (I don’t know enough about the built in architecture of it) so it supposed to be more famouse in the future as it covers lots of need.

But I'm interested to Share the first and most famous sample of every programming language here, take a look at "hello world" sample in NodeJS:

  1. var http = require('http');
  2. http.createServer(
  3.   function (request, response) {
  4.     response.writeHead(200, {'Content-Type': 'text/plain'});
  5.     response.end('Hello World\n');
  6.   }
  7. ).listen(8000);
  8. console.log('Server running at http://localhost:8000/');

At the first glance it's completely obvious that the JavaScript is base requirement for NodeJS.

References:

  1. http://nodejs.org/
  2. http://stackoverflow.com/questions/2353818/how-do-i-get-started-with-node-js
  3. http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js


Tags: NodeJs


comments powered by Disqus