DEV Community

Cover image for Super Power of Node Js
Md Pervez Hossain
Md Pervez Hossain

Posted on

Super Power of Node Js

What is a Server ? πŸ–₯

A Server is a computer system or Program that provides resources or data to client Computers through a network. Essentially, a server is a machine (like any computer) which is located somewhere .

  • Every domain name (like google.com) is linked to a unique IP address, which points to the server (a computer or machine) where the website is hosted.

  • When you type a domain name in the browser, it sends a request to that server, which responds by delivering the requested content (e.g., a web page) .

Example : πŸ’‘

If you set up a web server on your computer and store websites on it, your computer will act as the server. When users type the website's domain name (URL) into their browser, the browser sends a request to your server (your computer). Your server then responds by sending back the requested web pages.

In this case, your computer is functioning as a web server.

Javascript is the main Language which is used in the web browser for client site interactive behavior. But after node js you can use javascript on the server.

  • Node.js is built using JavaScript and C++ . But End Of the day it's C++ Programe.
  • Node.js uses the V8 JavaScript engine, which was developed by Google.
  • The V8 engine is a C++ program that executes JavaScript code.
  • JavaScript Engine is not a Physical Machine , it is a piece of software ( Piece of code ) that executes JavaScript code.
  • The V8 engine can be embedded into any C++ application, which has significantly contributed to the creation of Node.js.
  • Computers don’t understand JavaScript code directly. We write JavaScript code, and the V8 engine reads and compiles it into machine code that the computer can execute.
  • This is why Ryan Dahl wrote Node.js in C++ and utilized the V8 engine for compilation.
  • Js Engines Follow ECMAScript standards.
  • ECMAScript (often abbreviated as ES) is a standard for scripting languages. It defines the syntax, semantics, rules and behavior of programming constructs in JavaScript.
  • ECMAScript ensures that different JavaScript engines (like V8, SpiderMonkey, and JavaScriptCore) interpret the language in a consistent manner.
  • This consistent manner allows developers to write code that works across various platforms and environments.
  • V8 cannot connect to databases, can not access the file system, can not perform network calls, or fetch images and resources.
  • Its main job is to execute JavaScript code according to the core ECMAScript standard.
  • Along With V8 Engine , Node Js also adding its own powerful features.

JavaScript Runtime Environment :

  1. Node.js uses the V8 engine to execute JavaScript code, and it adds additional core features such as file system access, database connectivity, and networking.

  2. These features extend the capabilities of JavaScript, creating a runtime environment that allows JavaScript to be used for server-side applications.

  3. This combination of V8 and Node.js's built-in modules is known as the JavaScript Runtime Environment in Node.js.

Node.js Super Powers :

Non-Blocking, Asynchronous I/O: One of Node.js’s core strengths is its non-blocking I/O model, which allows it to handle multiple requests at the same time without waiting for one to finish before starting another. This makes Node.js extremely fast and efficient for tasks like file handling and network communication.

Event-Driven Architecture: Node.js has an event loop, which processes requests as per events. This architecture allows it to efficiently handle real-time data streams and applications like chat services or live dashboards.

Built-in Modules : Node.js provides many built-in modules (such as http, fs, path, etc.) that handle essential server-side functionalities like creating web servers, managing the file system, networking, and more. This allows developers to build powerful server applications quickly without needing external libraries.

  • http: Used to create web servers and handle HTTP requests.
  • fs: Used to interact with the file system (read/write files).
  • path: Used for working with and manipulating file paths in a cross-platform way.

Single-Threaded but Scalable: Although Node.js operates on a single thread, it can handle multiple operations concurrently due to its event loop and asynchronous nature. This allows Node.js to scale horizontally and handle large volumes of connections efficiently.

Cross-Platform: Node.js runs on various platforms, including Windows, Linux, and macOS. This makes it a versatile solution for different environments.

Full-Stack Development: Node.js allows developers to use JavaScript on both the client-side and server-side, enabling full-stack development with a single language

Streaming Capabilities: Node.js is excellent for handling data streaming applications, such as video streaming, file uploads, or real-time data transmission.

In Conclusion

Node.js is not just another JavaScript runtime. It is a powerful combination of the V8 JavaScript engine and C++-based extensions that provide server-side capabilities. By embedding V8, Node.js can execute JavaScript efficiently, but by adding features like file system access, database connectivity, and networking, it transforms into a full server environment.

Top comments (0)