Node.js introduction

Introduction to Node.js

NodeJS is a platform written in c++ for building scalable, high performance networked web app applications using Javascript. NodeJS was created by Ryan Dahl in 2009. NodeJs is used by a lot of big companies: IBM, Paypla, GoDaddy, and more. nodejs is a cross-platform runtime environment (code it once run it everywhere).

Where to use NodeJs?

NodeJS is a platform used to build web apps such as:

  • Realtime apps like Chat servers
  • Mutiplayer realtime games
  • Data streaming servers
  • Single page applications
  • APIs for mobile
  • Apps that require heavy I/O
  • Apps that require a high degree of scalability

Node.js infrastructure in a nutshell

NodeJS implements Google's javascript engine "google V8" written in c++ which is used by google chrome browser. A javascript engine is the one who is responsible for compiling and running javascript code and managing resources and memory allocation which means compiling your code from javascript to machine code.

NodeJS "chrome v8" is implemented with "LIBUV" Abstraction layer (library created in c++) which enable Node.js to perform seamless input and output operations (operation that happen on the lower level of the OS) across variant of operating systems in a non blocking way. along with LIBUV nodejs comes with a built-in core library that provides a lot of usefull methods that developers can use to write programs such as webservers and network apps,...

NodeJs is an asynchronous* language (on the contrary javascript and v8 are synchronous) that uses what we call events and non-bocking I/O to handle all requests which differs from other programs since NodeJs is a single threaded language and not a concurrent one (multi-threading).

All I/O is handled by the Node.js non blocking event loop (provided by LIBUV) which monitors for server events like Database query, File Read/Write, Network I/O.

Node.js is an asynchronous langage but only on events that are handled by LIBUV which means the tasks that are happens on core level in your OS (like reading files, networking, reading databases, etc) but all the code that is handled by v8 is synchronous.

Advantages of using NodeJs

  • Provides Event Driven & Non-Bloking I/O which is prfect for apps that requires heavy I/O.
  • You write your code from the server up which is perfect for networked & realtime apps.
  • Code in Javascript for javascript programmers.

What will you need to start using Node.Js

To start learning Node.js you will need the following software and knowledges:

  • Text Editor (i'm currently using Visual Studio Code)
  • Browser or Postman
  • Basic Knowledge of javascript and JSON format
  • Node and NPM (See intallation in the next chapter)