Ehsan Ghanbari

Experience, DotNet, Solutions

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 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



About Me

Ehsan Ghanbari

Hi! my name is Ehsan. I'm a developer, passionate technologist, and fan of clean code. I'm interested in enterprise and large-scale applications architecture and design patterns and I'm spending a lot of my time on architecture subject. Since 2008, I've been as a developer for companies and organizations and I've been focusing on Microsoft ecosystem all the time. During the&nb Read More

Post Tags
Pending Blog Posts
Strategic design
Factory Pattern
time out pattern in ajax
Selectors in Jquery
using Log4net in asp.net MVC4
How to use PagedList In asp.net MVC
Redis as a cache server
Domain driven design VS model driven architecture
What's the DDD-lite?
Multiple submit buttons in asp.net MVC