High-level Overview of NodeJS

High-level Overview of NodeJS

Introduction

This article is aimed at giving beginner developers a high-level understanding of what NodeJS is.

What is NodeJS?

As stated on the Node.js documentation: "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine".

Before we give an explanation of what that means, let's journey through some concepts.

JavaScript was initially limited to being run on the browser, for example, we could perform some updates on the DOM(Document Object Model) on the browser but, with the advent of NodeJS, we can now run JavaScript on the server. We can develop full-stack applications with only JavaScript.

Let's deal with the quote above: Firstly Node.js is built on a JavaScript engine called v8 engine (We have a lot of JavaScript engines and you can look that up online).

Just like other languages, JavaScript engines are designed to compile JavaScript codes into machine(readable) code(which is largely how the computer reads data). In the context of NodeJS, the engine that handles compiling JavaScript into machine code is the v8 engine and it is written in C++.

So for now, we can agree that the same engine that powers the Chrome browser powers Node.js.

What is a runtime?

In this article, we will consider a runtime to be somewhat a "container" that provides all that you need to perform a task.

For Chrome, the runtime provides tools that allow the chrome browser to perform tasks like DOM manipulation, custom event handling, etc.

For NodeJS, it does not have a DOM, and as such the runtime provides tools and libraries that allow developers to build server-based platforms that interact with the file system, etc.

NodeJS and Chrome are both written in C++, all they do is provide bindings for the v8 engine. This means when code is to be compiled to machine code by the v8 engine, part of what is sent for compilation is the c++ codes.

Considering the chrome browser, say we want to access an element on the dom using "getElementById" or "querySelector). what happens is that chrome also provides a c++ version of that code (through bindings) for the v8 engine to compile.

The same thing applies when we use NodeJS, say we want to read data from the file system, a binding in c++ is also created that matches our JavaScript code.

NodeJS Application

NodeJS finds application in various platforms ranging from flexibily, speed, easy-to-master(know JavaScript and you can get in as soon as fast), e.t.c

Thanks for reading and I hope you were able to learn something from me. I'm also open to honest feedback.