Blog

Filter posts by Category Or Tag of the Blog section!

Node.JS, Hello World!

Friday, 21 February 2014

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 enables 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 famous in the future as it covers lots of need.

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

 

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

 

At the first glance, it's completely obvious that the JavaScript is the 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

Category: Software

comments powered by Disqus