What you need to know about Node.js

What you need to know about Node.js

What is Node.js?

  • The idea of running JavaScript on the server is known as Node.JS
  • The original author of Node.js - Ryan Dahl, who has also currently release another cutting edge technology known as Deno.
  • Node.js is an open-source JavaScript run-time and cross-platform built on Google Chrome's V8 JavaScript engine.
  • Single-threaded, based on event-driven, and non-blocking I/O model
  • Node.js uses NPM packages for its development
  • It has proven to be the best tool for building fast, highly scalable network, and data-intensive applications.

Node.js Architecture behind the scenes

The underlying architecture of Node.js is made up of Node, JavaScript, V8, libuv, and C++. The five features give a higher level of abstraction that makes our lives easier as Node developers with great flexibility.

  1. V8 Engine
    • It enables Node.js to understand JavaScript codes that we write else it would have been impossible.
    • It is responsible to convert Node.js codes to machine codes that the computer can actually understand and execute effectively
  2. libuv
    • It is an open-source library with a strong focus on asynchronous I/O (Input/Output)
    • This layer is what gives Node.js access to operating systems, file systems, Networking, and et al
    • It implements the most two essential features of Node.js which are the:
      • Event Loop: this is responsible for executing simple tasks like Callbacks, Network IO, and et al
      • Thread Pool: Responsible for more heavy work like File access, compression, and et al
  3. The V8 and Libuv are all written in C++ while V8 also has in its library some JavaScript codes. That's to say Node.js is a language written in JavaScript and C++

Use Node.js for:

  • Data Streaming
  • API with a database behind (preferably NoSQL Databases)
  • Real-time chat application
  • Server-side web apps
  • Hardware programming

Don't use Node.js for:

  • Applications with heavy server-side processing (High CPU Intensive usage)

Let's install Node.js

  • Head unto => Node.JS
  • Select the version that supports your OS platform. LTS (Long Term Support) versions are highly recommended; because they are stable.
  • Download it and install it.
  • Remember to read and accept the apt instruction at each stage.

Testing if Node.js is installed correctly

  • Launch your terminal or CLI (Command Line Interface) and type the command below:
          node -v or node --version

Kind regards...