What is node.js?


Node.js is a leading-edge event-driven system, which is used to set up scalable applications. It is built with Google’s V8 JavaScript Engine and it handles requests and responses between a server and an enormous number of online users more efficiently than any conventional system. What makes Node.js one of a kind is the fact that in contrast to conventional systems that handle the information in massive hunks, it handles everything in little bits. For example, in case a user needs to fill a couple of fields on a website, Node.js processes the info from the first field the second it is inserted, utilizing the server’s processing power more effectively. In contrast, traditional systems wait for all the fields to be filled and while the information from them is being processed, requests from other users stay in the queue. The difference may be insignificant for a single person, but it truly does make a difference if a huge number of individuals are browsing a site at the very same time. Several examples of sites where Node.js can be used are dinner reservation portals, chat rooms or interactive browser game portals, i.e. sites that support quick live interaction.

As an asynchronous event driven JavaScript runtime, Node is designed to build scalable network applications. In the following “hello world” example, many connections can be handled concurrently. Upon each connection the callback is fired, but if there is no work to be done, Node will sleep.

const http = require('http');

const hostname = '';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello Worldn');

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);

This is in contrast to today’s more common concurrency model where OS threads are employed. Thread-based networking is relatively inefficient and very difficult to use. Furthermore, users of Node are free from worries of dead-locking the process, since there are no locks. Almost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, scalable systems are very reasonable to develop in Node.

Node.js is a trademark of Joyent, Inc.

Official website: Nodejs.org

Leave a Reply

Your email address will not be published.Email address is required.