Node.js Tutorial – Learn basics of Node.js

Node.js Tutorial

Welcome to Node.js Tutorial – Following these lucid tutorials helps you learn basic understanding of Node.js. With the progression of your learning, more advanced concepts to program and build server side applications and networking applications are provided.

Node.js Tutorial

 

An introduction to Node.js

Node.js if free to use and is an open source server framework. Node.js runs on various platforms and some of them are Linux, Unix, Windows, Mac OS X, etc.

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. The two features that make Node.js stand-out are :

  1. Event-driven
  2. Non-blocking I/O model

To appreciate the features of Node.js and how it revolutionized the server side applications in terms of resource usage and event handling, we might need to take a sneak peak into the traditional model of web servers. And know how Node.js fill the performance voids.

In a traditional web server, when a web-client (browser or an application) makes a request, server takes the request and waits for the response to be prepared by file system/database/any other resource. Consider that your web service has become popular and number of web-client requests hitting the server is increasing day by day. But if you observe, the server is serving one request at a time and while the file-system/database is preparing the response, the server is being idle, instead of taking requests from other customers. Node.js exploits this idle time with its event-driven framework. That is after taking a request, the server tries to prepare the response. And if there is any resource (file-system/database/etc) involved to prepare the response, server is let free and is informed through events when the response is ready. Mean while, instead of being idle during this time, server takes requests from other clients. When a response for a client is ready, an event is generated to let the server know the response is ready, which is in turn served to clients.

 

Programming Node.js Applications

Node.js is a platform built on JavaScript engine. Node.js applications could be developed using Java Scripting and most of the modern web applications are being built using Node.js. And this is  also one of the important factor for Node.js to become popular as there is a wide community of JavaScript developers out there. They adopted Node.js, thus industry adopted Node.js quite easily.

Following are some of the capabilities of Node.js:

  • Node.js can dynamically generate content and present it to web clients
  • Node.js can do file operations like read, write, update, delete, etc.
  • Node.js can collect data from clients through forms.
  • Node.js can connect to various databases like MySQL, MongoDB, etc., and perform respective DB operations.
  • Node.js has builtin JSON module to work with JSON files.

 

Node.js Production Ready

Currently Node.js v8.x is the latest Long Term Supported version. So, most of the examples you come across in this tutorial are tried out on Node.js v8.x.

 

Node.js Use Cases

Following are some of the notable use cases that can take advantage of the Node.js Event driven model.

  • Low latency provided by Node.js makes it suitable for Real-time applications like instant messaging, online-gaming and collaborative applications like Google Docs etc.
  • Doing tasks asynchronously makes Node.js scale for a much higher traffic.
  • Node.js can scale horizontally using its cluster mode. So, if you are looking for a scalable web application, Node.js is there.

 

Node.js Limitations

Following are some of the limitations of Node.js

  • Node.js is not a good choice for applications that do heavy computation. This is because incoming requests are blocked during computation tasks that take relatively long time.
  • Security provided by many of npm packages are not promising, even though core Node.js is quite stable. You may have to depend on third party tools to evaluate a package for any known vulnerabilities before using it in your application.

 

Node.js Tutorial Index

Following is the list of tutorials that are well explained with simplified examples to learn Node.js easily.