Introduction to Node.js — A Quick Start

Smsstemburu
4 min readSep 13, 2021

In this blog I’d like to give a complete idea from A-Z on Node.js. This includes

  1. What’s Node.js
  2. Why is Node.js
  3. A brief history of Node.js
  4. Prerequisites for learning Node.js
  5. Why Node.js if Browser ?

What’s Node.js

Node.js is an open-source and cross platform(works on multiple platforms like Windows, OSX and Linux) JavaScript runtime environment which means Node.js platform is used to execute JavaScript code on server-side.

Node.js runs on the V8 engine, the core of google chrome and executes JavaScript code outside a web browser.

A Node.js app runs in a single process, without creating a new thread for every request. Node.js provides a set of asynchronous I/O primitives in its standard library that prevents JavaScript code from blocking and generally, libraries in Node.js are written using non-blocking pattern. We’ll be discussing in depth regarding this in “Architecture of Node.js”.

Why’s Node.js

Following are the few things that make Node.js the first choice for developers

  1. Asynchronous and Event Driven — JavaScript is an event-driven language which means there’ll be a main loop that listens for events, and then triggers a callback function when one of those events is detected. Node uses this to its advantage to produce highly scalable servers. Using an architecture called an event loop, Node makes programming highly scalable servers both easy and safe. Let me give you an example to understand better, When Node.js performs an I/O operation, like reading from the network, accessing a database or the filesystem, instead of blocking the thread and wasting CPU cycles waiting, Node.js will resume the operations when the response comes back which makes it asynchronous. This kind of architecture reduces complexity.
  2. Very Fast As it’s build on Google Chrome’s V8 JavaScript Engine, Node.js code execution is really fast.
  3. Single Threaded but Highly Scalable — Node.js uses single threaded model with event looping which makes server to respond in a non-blocking way and makes the server highly scalable as opposed to traditional servers in which it could handle only limited requests.
  4. No Buffering — Node.js never buffer any data rather it outputs the data in the form of chunks.
  5. Single scripting language for both Client & Server side — Node.js has a unique advantage because millions of frontend developers that write JavaScript for the browser are now able to write the server-side code in addition to the client-side code without the need to learn a completely different language.

A brief history of Node.js

Node.js was developed by Ryan Dahl in 2009 and it is thirteen years old. Thirteen years isn’t a very long time in tech, but Node.js seems to have been around forever.

2009

  • Node.js is born
  • The first form of npm is created

2010

2011

  • npm hits version 1.0
  • Larger companies start adopting Node.js: LinkedIn, Uber, etc.
  • hapi(Hapi is a Javascript framework that can provide API development opportunities for servers, websites, and HTTP proxy applications) is born

2012

  • Adoption continues very rapidly

2013

  • First big blogging platform using Node.js: Ghost
  • Koa(Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs) is born

2014

  • The Big Fork: io.js is a major fork of Node.js, with the goal of introducing ES6 support and moving faster

2015

  • The Node.js Foundation is born
  • IO.js is merged back into Node.js
  • npm introduces private modules
  • Node.js 4 (versions 1, 2 and 3 never previously released)

2016

2017

  • npm focuses more on security
  • Node.js 8
  • HTTP/2
  • V8 introduces Node.js in its testing suite, officially making Node.js a target for the JS engine, in addition to Chrome
  • 3 billion npm downloads every week

2018

  • Node.js 10
  • ES modules .mjs experimental support
  • Node.js 11

2019

  • Node.js 12
  • Node.js 13

2020

  • Node.js 14
  • Node.js 15

2021

  • Node.js 16

Prerequisites for learning Node.js

At beginning you might be confused where to start and where to end, I’d like to guide you through the process.

I would recommend you to have a good grasp of the main JavaScript concepts before diving into Node.js:

  • Lexical Structure
  • Expressions
  • Types
  • Classes
  • Variables
  • Functions
  • this
  • Arrow Functions
  • Loops
  • Scopes
  • Arrays
  • Template Literals
  • Semicolons
  • Strict Mode
  • ECMAScript 6, 2016, 2017

With those concepts in mind, you are well on your road to become a proficient JavaScript developer, in both the browser and in Node.js.

The following concepts are also key to understand asynchronous programming, which is one fundamental part of Node.js:

  • Asynchronous programming and callbacks
  • Timers
  • Promises
  • Async and Await
  • Closures
  • The Event Loop

I’d like to suggest you to gain a good knowledge with the fundamentals and then start with the next steps of Node.js.

Why Node.js if Browser ?

Do you have the same query in your mind?

If both Browser and Node.js uses JavaScript as their programming language, Why Node.js again ?

Let me clear your query in step by step :)

  1. Node.js apps bring with them a huge advantage: the comfort of programming everything — the frontend and the backend — in a single language.
  2. And in the browser, we don’t have all the nice APIs that Node.js provides through its modules, like the filesystem access functionality.
  3. Another big difference is that in Node.js you control the environment.
  4. JavaScript moves so fast, but browsers can be a bit slow to upgrade, sometimes on the web you are stuck with using older JavaScript / ECMAScript releases.

Thus we’ve landed to the end of the topic, Hope I’ve given informative & solid intro on Node.js, Do let me know if any queries or things to be added/modified. Please feel free to share your ideas on future blogs to be posted :).

--

--

Smsstemburu

A tech-ruminate, Inquisitive and willing to learn new technologies to tackle real-time problems & build real-time web applications