NodeJS Introduction

📔 : NodeJS 🔗

Node.js एक open-source server side runtime environment है जो Chrome के V8 JavaScript engine इंजन पर बनाया गया है। यह JavaScript का use करके scalable server-side applications के लिए एक event driven, non-blocking (asynchronous) I/O and cross-platform runtime environment provide कराता है।

NodeJS कोई language नहीं है , यह run time open source development platform जो JavaScript Code को server side run करता है।

अगर आपको JavaScript की knowledge नहीं है तो आप हमारी website पर free में JavaScript Tutorials पढ़ सकते हैं।


NodeJs का use करके कई तरह के command line applications, web applications, real-time chat applications, REST API etc. बनाये जाते हैं।

what is Non-blocking/Asynchronous ?

Asynchronous का मतलब है , कि एक time पर same client की multiple requests handle करना। Normally क्या होता है कि जब client server पर request send करता है। तो वो request complete होने तक server दूसरी request handle करने के लिए wait करता है।


लेकिन NodeJS के साथ ऐसा नहीं है , current request process करते हुए भी , NodeJs Servers दूसरी request handle करने के लिए ready रहता है। जिससे directly efficiency & performance दोनों increase होते हैं।

Non-blocking/Asynchronous को समझने के लिए हम PHP और NodeJS का छोटा सा example देखते हैं।

Copy Fullscreen Close Fullscreen
<?php
echo "Start \n";
foreach(range(1, 5) as $num)
{
  echo "{$num} \n";

  //delay execution for 1 second
  sleep(1);
}
echo "End";
Output
Start
1
2
3
4
5
End

Example में आप देख सकते हैं कि execution delay होने के बाद भी code को line wise execute किया गया है। चाहे जितनी देर का delay हो PHP Script उस code को run करके ही आगे run होगी। Same तरह के example को अब NodeJS में run करते हैं।

Copy Fullscreen Close FullscreenRun
console.log("Start");
setTimeout(() => {
  //delay execution for 1 second.
  console.log("Code After 1 second");
}, 1000);
console.log("End");
C:\Users\HP\Desktop\workspace\nodejs>node test.js
Start
End
Code After 1 second

Output में आप देख सकते हैं कि NodeJS में ऐसा नहीं हुआ , जिस code को run करने के लिए wait करना पड़ रहा उसे बाद में execute किया है। तब तक next code run हो रहा है। इसी behavior की वजह से NodeJS को Non-blocking/Asynchronous कहा गया है।

NodeJS History

NodeJS को Ryan Dahl द्वारा 2009 में introduce किया गया था , और अभी NodeJS का current version 16 है।

Advantages Of NodeJS

  1. Free & Open Sourcse

    NodeJS free और open source है , मतलब आपको कोई Pay नहीं करना पड़ेगा आप आसानी से install और use कर  सकते है |

  2. Cross Platform

    NodeJS को आप किसी भी Operating System पर रन कर सकते है। चाहे बो Linux , Window , Unix किसी भी तरह के Operating System पर run कर सकते है।

  3. Performence

    Non - Blocking और Asynchronous होने की वजह से performance बहुत अच्छी है

  4. Easy To Use

    NodeJS use करने के लिए बहुत ही easy language है , अगर आप थोड़ा सा भी JavaScript language के बारे में जानते हैं तो आप बहुत आसानी से इसे सीख सकते है

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers