Introduction to Node.js

Introduction 

Node.js is definitely not a new language, and it is not just a framework on JavaScript. It can be considered as a runtime environment for JavaScript built on top of Google's V8engine.Nodeprovides, a purely event-driven, non-blocking infrastructure for building highly concurrent software.

Example:

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

Strength &weakness of Node.JS

 

  1. There is a certain class of problems in which its strengths shine through.

  2. CPU bound problems benefit from an increase in the number of clock cycles available for computation.

  3. Prime number calculation is a good example.

  4. I/O bound problems are increased throughput I/O it is as disk, memory, network bandwidth, and improved data caching.

  5. It’s based on not blocking, asynchronous architecture designed for concurrency.

When to use Node.js

It is good for application development that accepts concurrent connections. It is most suited for applications. Each incoming request requires a few CPU cycles.

If you intend to do computation intensive tasks, at the request it will be the end of blocking the event loop.

Node.js suited for real time apps like online games, collaboration tools,  online chats, and similar.

Now the point comes to how we will decide whether we use it or not, so don’t worry if you should analyze the app context seriously and find out where you use it in the proper way.

Node js uses some of the folowing concepts:

  1. Debugger: Statement inserting debugger; in code of java script will help to enable break point.
  2. Modules: Node.js supported simple module loading system.
  3. Console: Console module provides debugging feature that is similar in java script console by browser.
  4. Streaming: By various object in node js it is abstract interface implemented.
  5. Cluster: It allows us to create child process easily that share server port.
  6. DNS: DNS module contains functions.
  7. Add-ons: It is dynamically linked share object.
  8. Domain: It provides way to handle multiple different IO operation as a single group.
  9. Buffer: It is similar to array of integers but correspond to fixed-sized.
  10. Global: It available for all modules.
  11. Net: It provide asynchronous network wrapper.
  12. Call backs: It called when given task will be completed.
  13. Error handling: It supports various types of categories error.
  14. Crypto: It provides cryptographic functionality that includes a set of wrapper for Open SSL’s hash.

Node.JS

Here is a  list some companies whose use Node.js:

Go Daddy, Microsoft, PayPal, Uber, Wikipins, Yahoo! and eBay.

Hi Friends. Thanks for reading my article,  if you have any query please message or comment.

Next Recommended Reading Running JavaScript Files in Node.js