SlideShare une entreprise Scribd logo
1  sur  13
Explained by Ankit Chawla
WHAT TO EXPECT AHEAD….
 Introduction
 Some Theory
 Examples
 Unbelievable benchmarks
BACKGROUND
 V8 is an open source JavaScript engine developed by Google.
Its written in C++ and is used in Google Chrome Browser.
 Node.js runs on V8.
 It was created by Ryan Dahl in 2009.
 Latest version is 10.0.0
 Is Open Source. It runs well on Linux systems, as well as on
Windows systems.
 If you have worked on EventMachine (Ruby) or Python’s
Twisted or Perl’s AnyEvent framework then following
presentation is going to be very easy.
INTRODUCTION: BASIC
 In simple words Node.js is ‘server-side JavaScript’.
 In not-so-simple words Node.js is a high- performance
network applications framework, well optimized for high
concurrent environments.
 It’s a command line tool.
 In ‘Node.js’ , ‘.js’ doesn’t mean that its solely written JavaScript.
It is 40% JS and 60% C++.
 From the official site:
‘Nodes goal is to provide an easy way to build scalable network
programs’
INTRODUCTION: ADVANCED
 Node.js uses an event-driven, non-blocking I/O model, which
makes it lightweight.
 It makes use of event-loops via JavaScript’s callback
functionality to implement the non- blocking I/O.
 Programs for Node.js are written in JavaScript but not in the
same JavaScript we are use to.
 There is no DOM implementation provided by Node.js, i.e. you
can not do this: var element =
document.getElementById(‚elementId‛);
 Everything inside Node.js runs in a single-thread.
EXAMPLE: GETTING STARTED &
HELLOWORLD
 Install/build Node.js. (Yes! Windows installer is available!)
 Open your favorite editor and start typing JavaScript. When you are
done, open cmd/terminal and type this: ‘node YOUR_FILE.js’
 Here is a simple example, which prints ‘hello world’
var sys = require(‘sys’);
setTimeout(function() {
sys.puts(‚world‛);
},3000);
sys.puts(‚hello‛);
//it prints ‘hello’ first and waits for 3 seconds and then prints ‘world’
SOME THEORY: EVENT-LOOPS
 Event-loops are the core of event-driven programming, almost
all the UI programs use event-loops to track the user event, for
example: Clicks, Ajax Requests etc. Clients send HTTP requests
Client to Node.js serverEvent loop returns An Event-loop is
woken up by OS,result to client passes request and response
objects Event loop to the thread-pool (main thread) Long-
running jobs run on worker threads C++Response is sent
Threadpoolback to main thread (workervia callback threads)
SOME THEORY: NON-BLOCKING I/O
 Traditional I/O
var result = db.query(‘select x from table_Y’);
doSomethingWith(result); //wait for result!
doSomethingWithOutResult(); //execution is blocked!
 Non-traditional, Non-blocking I/O
db.query(‘select x from table_Y’,function (result){
doSomethingWith(result); //wait for result! });
doSomethingWithOutResult(); //executes without any delay!
WHAT CAN YOU DO WITH NODE.JS ?
 You can create an HTTP server and print ‘hello world’ on the
browser in just 4 lines of JavaScript.
 You can create a TCP server similar to HTTP server, in just 4
lines of JavaScript.
 You can create a DNS server.
 You can create a Static File Server.
 You can create a Web Chat Application like GTalk in the
browser.
 Node.js can also be used for creating online games,
collaboration tools or anything which sends updates to the
user in real-time.
WHEN TO USE NODE.JS?
 Node.js is good for creating streaming based real- time
services, web chat applications, static file servers etc.
 If you need high level concurrency and not worried about
CPU-cycles.
 If you are great at writing JavaScript code because then you
can use the same language at both the places: server-side and
client-side.
 More can be found at:
http://stackoverflow.com/questions/5062614/how- to-decide-
when-to-use-nodejs
BENCHMARKS
ANY QUESTIONS
??

Contenu connexe

Tendances

Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Fwdays
 

Tendances (20)

Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
D3_Tuto_GD
D3_Tuto_GDD3_Tuto_GD
D3_Tuto_GD
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Internals of AsyncTask
Internals of AsyncTask Internals of AsyncTask
Internals of AsyncTask
 
Workshop React.js
Workshop React.jsWorkshop React.js
Workshop React.js
 
React on es6+
React on es6+React on es6+
React on es6+
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)
 
JavaScript + Jenkins = Winning!
JavaScript + Jenkins = Winning!JavaScript + Jenkins = Winning!
JavaScript + Jenkins = Winning!
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
 
A Closer Look At React Native
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React Native
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciolla
 
Starting with Reactjs
Starting with ReactjsStarting with Reactjs
Starting with Reactjs
 
How to unit test your React/Redux app
How to unit test your React/Redux appHow to unit test your React/Redux app
How to unit test your React/Redux app
 
Exploit ie using scriptable active x controls version English
Exploit ie using scriptable active x controls version EnglishExploit ie using scriptable active x controls version English
Exploit ie using scriptable active x controls version English
 
Node azure
Node azureNode azure
Node azure
 
Node.js concurrency
Node.js concurrencyNode.js concurrency
Node.js concurrency
 
xlab #7 - ReactJS & NodeJS
xlab #7 - ReactJS & NodeJSxlab #7 - ReactJS & NodeJS
xlab #7 - ReactJS & NodeJS
 

Similaire à Node

Why Node.js
Why Node.jsWhy Node.js
Why Node.js
guileen
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
Edureka!
 

Similaire à Node (20)

Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Proposal
ProposalProposal
Proposal
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Nodejs
NodejsNodejs
Nodejs
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
Real time web
Real time webReal time web
Real time web
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 
Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easy
 
Nodejs Intro Part One
Nodejs Intro Part OneNodejs Intro Part One
Nodejs Intro Part One
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
Node js
Node jsNode js
Node js
 
Nodejs
NodejsNodejs
Nodejs
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
02 Node introduction
02 Node introduction02 Node introduction
02 Node introduction
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Node

  • 2. WHAT TO EXPECT AHEAD….  Introduction  Some Theory  Examples  Unbelievable benchmarks
  • 3. BACKGROUND  V8 is an open source JavaScript engine developed by Google. Its written in C++ and is used in Google Chrome Browser.  Node.js runs on V8.  It was created by Ryan Dahl in 2009.  Latest version is 10.0.0  Is Open Source. It runs well on Linux systems, as well as on Windows systems.  If you have worked on EventMachine (Ruby) or Python’s Twisted or Perl’s AnyEvent framework then following presentation is going to be very easy.
  • 4. INTRODUCTION: BASIC  In simple words Node.js is ‘server-side JavaScript’.  In not-so-simple words Node.js is a high- performance network applications framework, well optimized for high concurrent environments.  It’s a command line tool.  In ‘Node.js’ , ‘.js’ doesn’t mean that its solely written JavaScript. It is 40% JS and 60% C++.  From the official site: ‘Nodes goal is to provide an easy way to build scalable network programs’
  • 5. INTRODUCTION: ADVANCED  Node.js uses an event-driven, non-blocking I/O model, which makes it lightweight.  It makes use of event-loops via JavaScript’s callback functionality to implement the non- blocking I/O.  Programs for Node.js are written in JavaScript but not in the same JavaScript we are use to.  There is no DOM implementation provided by Node.js, i.e. you can not do this: var element = document.getElementById(‚elementId‛);  Everything inside Node.js runs in a single-thread.
  • 6. EXAMPLE: GETTING STARTED & HELLOWORLD  Install/build Node.js. (Yes! Windows installer is available!)  Open your favorite editor and start typing JavaScript. When you are done, open cmd/terminal and type this: ‘node YOUR_FILE.js’  Here is a simple example, which prints ‘hello world’ var sys = require(‘sys’); setTimeout(function() { sys.puts(‚world‛); },3000); sys.puts(‚hello‛); //it prints ‘hello’ first and waits for 3 seconds and then prints ‘world’
  • 7. SOME THEORY: EVENT-LOOPS  Event-loops are the core of event-driven programming, almost all the UI programs use event-loops to track the user event, for example: Clicks, Ajax Requests etc. Clients send HTTP requests Client to Node.js serverEvent loop returns An Event-loop is woken up by OS,result to client passes request and response objects Event loop to the thread-pool (main thread) Long- running jobs run on worker threads C++Response is sent Threadpoolback to main thread (workervia callback threads)
  • 8.
  • 9. SOME THEORY: NON-BLOCKING I/O  Traditional I/O var result = db.query(‘select x from table_Y’); doSomethingWith(result); //wait for result! doSomethingWithOutResult(); //execution is blocked!  Non-traditional, Non-blocking I/O db.query(‘select x from table_Y’,function (result){ doSomethingWith(result); //wait for result! }); doSomethingWithOutResult(); //executes without any delay!
  • 10. WHAT CAN YOU DO WITH NODE.JS ?  You can create an HTTP server and print ‘hello world’ on the browser in just 4 lines of JavaScript.  You can create a TCP server similar to HTTP server, in just 4 lines of JavaScript.  You can create a DNS server.  You can create a Static File Server.  You can create a Web Chat Application like GTalk in the browser.  Node.js can also be used for creating online games, collaboration tools or anything which sends updates to the user in real-time.
  • 11. WHEN TO USE NODE.JS?  Node.js is good for creating streaming based real- time services, web chat applications, static file servers etc.  If you need high level concurrency and not worried about CPU-cycles.  If you are great at writing JavaScript code because then you can use the same language at both the places: server-side and client-side.  More can be found at: http://stackoverflow.com/questions/5062614/how- to-decide- when-to-use-nodejs