Introduction to node.js


Let’s start with history,
In the earlier time JAVASCRIPT was only limited to Web Browser, No one can even think about to run JAVASCRIPT outside the web browser but then Ryan Dahl came in the picture and build it.
Now let’s know what sort of things he did to build this:
In the browser there is JS engine which is responsible for executing the JS but this JS engine only available in the browser.
And every browser has there own JS engine like Chrome has v8, Firefox has Spider Monkey, Safari has Apple’s JS engine So on and so forth
Now here Ryan Dahl embed the V8 engine with C++ and this project is known as Node.js
Now Let’s talk about it’s benefits:
now you can run JS outside of the browser because of v8 engine present in node.js
Now JS can talk to native machine because of C++
you can create webservers in JS language
Now let’s see the main components of node.js
1. V8 JavaScript Engine:
Parses, compiles, and executes JavaScript code
Provided by Google (same engine used in Chrome).
Converts JS into high-performance machine code.
Does NOT include any Node-specific features like
fs
,http
, etc.
2. Libuv:
A library that provides:
The event loop
Asynchronous I/O (e.g., file system, networking)Enables non-blocking, async behavior in Node.js.
3. Node.js Standard Library (Built-in Modules)
A set of core modules written in JS + C++ bindings.
Examples:
fs
→ file systemhttp
→ create serverspath
,os
,crypto
,stream
,events
, etc.
These modules use the bindings to call low-level system features.
4. Node.js APIs
Functions like:
setTimeout
,setImmediate
,require
,module.exports
These are provided by Node not by V8.
🏹Let’s understand some terminology:
☀️Input/Output (I/O) refers to operations like:
Reading/writing files
Network requests (API calls)
Accessing databases
User input from keyboard, mouse, etc.
☀️blocking I/O means:
These I/O operations do block the execution of your program.
☀️ Non-blocking I/O means:
These I/O operations do not block the execution of your program.
The program can continue running other code while waiting for the I/O to finish.
Once the I/O is done, a callback or promise is triggered to handle the result.
🐦🔥Why Node.js is Perfect for Building Fast Web Apps:
Node.js has become one of the most popular choices for building high-performance web applications, especially those that require speed, scalability, and real-time capabilities:
1. Non-blocking, Asynchronous I/O
Node.js uses non-blocking I/O and an event-driven model, thanks to libuv.
This means it doesn’t wait for file reads, network calls, or database queries.
While waiting for I/O, it keeps serving other requests → making it super fast and efficient.
2. Single-threaded but Highly Scalable
Node.js runs on a single thread using an event loop.
That might sound like a limitation, but with async I/O, it can handle massive numbers of concurrent connections with minimal resources.
It avoids the heavy context-switching overhead seen in multi-threaded servers (like Java or PHP).
3. Built on V8 Engine
Node.js uses Google’s V8 engine, which compiles JavaScript to highly optimized machine code.
This means your JS code runs almost as fast as C++ in many cases.
4. Same Language for Frontend & Backend
You can build the entire app in JavaScript, both client and server.
This means:
Reuse of code (e.g., validation logic)
Easier onboarding for teams
Faster development cycles
5. Rich Ecosystem (NPM)
Node.js has npm (Node Package Manager), the world’s largest software registry.
Thousands of libraries and modules let you build apps quickly.
6. Perfect for Real-Time Apps
Apps like chat apps, gaming servers, live dashboards, etc., need real-time updates.
Node.js supports WebSockets and real-time communication out of the box, making it ideal for such use cases.
7. Microservices & Serverless Friendly
- Node.js is lightweight and modular, perfect for building microservices.
Subscribe to my newsletter
Read articles from KISHAN THAPA directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
