SlideShare a Scribd company logo
Introduction to Node.js
Single threaded, non-blocking, asynchronous runtime
(server side Javascript)
About me?
NodeXperts?
Premier Software Development Services Company.
Build & Deliver for Node.js.
Tremendous work in :
Angular.js,
D3.js,
Meteor.js,
ReactJs and many more.
intro to Javascript.
What the heck is an event loop?
What is javascript?
JavaScript has “event-loop”, “callback” and a stack.
It is “asynchronous”, “single-threaded” and “non-blocking”.
It uses v8 engine for runtime.
What does it mean?
Everything revolves around “event loop”.
V8 Engine?
Stack Call?
function foo2() {
console.log(“hello world”);
}
function foo1() {
foo2();
}
foo1();
Stack:
Finally: hello world
foo2()
foo1()
main()
What happen when we run code synchronously in
single threaded environment?
var request1 =
$.getSync(‘http://xyz.com’);
var request2 =
$.getSync(‘http://xyz1.com’);
console.log(request1);
console.log(request2)
What will happen?
1.request1 will process, then
wait for the response.
2.Request2 will process, again
wait for response.
Why? Coz thread is busy processing
that request.
Then, how Javascript works asynchronously?
The answer lies in event loop?
What this event loop is?
Let’s see...
What is Node.js then?A server side v8 engine
I hope you now have a basic idea of how javascript
works on browser?
What? Now we can run javascript on server side.
Yes, it allows us to run JavaScript code in the backend,
outside a browser.
How? Google's V8 VM.
Comes with two things: a runtime environment and a library
(NPM).
Sounds awesome, right?
Features of Node Js
Relies on asynchronous code to stay fast and non-blocking.
Non-blocking
Blocking:
console.log("Hi!");
for(var i=0; i<100; i++) {
console.log("Inside the loop");
}
console.log("Welcome to NodeXperts.");
Continue...
Non-blocking:
console.log("Hi!");
setTimeout(function timeout() {
for(var i=0; i<100; i++) {
console.log("Inside the loop");
}
}, 5000);
console.log("Welcome to NodeXperts.");
Where does it go? It goes inside EVENT LOOP (through
callbacks).
Let’s take a look at an example
var fs = require('fs');
fs.readFile('nx.txt', function (err, data){
if(err) throw err;
console.log(data);
})
While there are events to process:
e = get the next event
Perform the action requested by e in thread
If e’s thread is complete and there is a callback associated with e:
Call the callback
Continue...
Event Loop: How it is different from browser?
Where you can use Node Js?
Few CPU cycles
I/O operations
Chat Applications
Proxies
Where you can not use Node Js?
Heavy computation.
Large and complicated web application because it doesn’t
support multi-threaded programming.
Advantages of Node Js
Open source
JavaScript language is used on both front-end & back-end
High Scalability both Horizontally & Vertically
Better Performance than traditional web servers
Has a wide community of developers around the world
Thank you
Any questions?
Hope you all enjoyed :)

More Related Content

PDF
Non-blocking I/O, Event loops and node.js
PDF
PPT
Java concurrency introduction
PDF
Node.js - A Quick Tour
PDF
(WS14) Sasa Matijasic - Node.js i "novi" web
PPT
New kid on the block node.js
PDF
How to Write Node.js Module
PPTX
Async java8
Non-blocking I/O, Event loops and node.js
Java concurrency introduction
Node.js - A Quick Tour
(WS14) Sasa Matijasic - Node.js i "novi" web
New kid on the block node.js
How to Write Node.js Module
Async java8

What's hot (20)

PDF
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
PDF
Scalable Socket Server by Aryo
PPTX
The State of JavaScript (2015)
KEY
Don’t block the event loop!
PPT
Владимир Мигуро "Дао Node.js"
PDF
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
PDF
Nodejs - A quick tour (v6)
PDF
Node.js Lab
PPTX
Event-driven IO server-side JavaScript environment based on V8 Engine
PPTX
The Node.js Event Loop: Not So Single Threaded
PDF
Connecting to the network
PPT
Nodejs quick start
PDF
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
PDF
Node Web Development 2nd Edition: Chapter3 Node Modules
PDF
Node intro
PDF
Multi-core Node.pdf
KEY
Node.js - As a networking tool
PDF
Introduction to Erebos: a JavaScript client for Swarm
PDF
Tarantool как платформа для микросервисов / Антон Резников, Владимир Перепели...
PDF
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
Scalable Socket Server by Aryo
The State of JavaScript (2015)
Don’t block the event loop!
Владимир Мигуро "Дао Node.js"
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Nodejs - A quick tour (v6)
Node.js Lab
Event-driven IO server-side JavaScript environment based on V8 Engine
The Node.js Event Loop: Not So Single Threaded
Connecting to the network
Nodejs quick start
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Node Web Development 2nd Edition: Chapter3 Node Modules
Node intro
Multi-core Node.pdf
Node.js - As a networking tool
Introduction to Erebos: a JavaScript client for Swarm
Tarantool как платформа для микросервисов / Антон Резников, Владимир Перепели...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Ad

Similar to Introduction to Node.js (20)

PPTX
PPTX
PDF
Tech io nodejs_20130531_v0.6
PPTX
What is Node.js
PPTX
02 Node introduction
PPT
18_Node.js.ppt
PDF
Node js internal
PPT
18_Node.js.ppt
PPTX
concept of server-side JavaScript / JS Framework: NODEJS
PPTX
Kalp Corporate Node JS Perfect Guide
PDF
Node.js introduction
PPTX
PDF
Basic Understanding and Implement of Node.js
PPTX
Nodejs intro
PPT
Introduction to node.js aka NodeJS
PDF
540slidesofnodejsbackendhopeitworkforu.pdf
PPTX
Introduction to Node.js
PPTX
Introduction to NodeJS
PPTX
An overview of node.js
PPT
Introducción y comandos en NodeJS slodte
Tech io nodejs_20130531_v0.6
What is Node.js
02 Node introduction
18_Node.js.ppt
Node js internal
18_Node.js.ppt
concept of server-side JavaScript / JS Framework: NODEJS
Kalp Corporate Node JS Perfect Guide
Node.js introduction
Basic Understanding and Implement of Node.js
Nodejs intro
Introduction to node.js aka NodeJS
540slidesofnodejsbackendhopeitworkforu.pdf
Introduction to Node.js
Introduction to NodeJS
An overview of node.js
Introducción y comandos en NodeJS slodte
Ad

More from NodeXperts (20)

PDF
ECMA Script
PDF
Apollo Server IV
PDF
React Context API
PDF
Devops - Microservice and Kubernetes
PDF
Introduction to EC2 (AWS)
PDF
Reactive Application Using METEOR
PDF
Apollo server II
PDF
Apollo Server
PDF
Apollo Server III
PPTX
Getting Reactive Data
PPTX
State, Life cycle, Methods & Events
PPTX
Refs in react
PPTX
Flow router, components and props
PPTX
Using react with meteor
PPTX
Introduction to Reactjs
PPTX
Mobile apps using meteor - Part 1
PPTX
Microservice architecture : Part 1
PPTX
Reactive web applications using MeteorJS
PPTX
Improving build solutions dependency management with webpack
PPTX
Meteor workshop
ECMA Script
Apollo Server IV
React Context API
Devops - Microservice and Kubernetes
Introduction to EC2 (AWS)
Reactive Application Using METEOR
Apollo server II
Apollo Server
Apollo Server III
Getting Reactive Data
State, Life cycle, Methods & Events
Refs in react
Flow router, components and props
Using react with meteor
Introduction to Reactjs
Mobile apps using meteor - Part 1
Microservice architecture : Part 1
Reactive web applications using MeteorJS
Improving build solutions dependency management with webpack
Meteor workshop

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation theory and applications.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
Teaching material agriculture food technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
DOCX
The AUB Centre for AI in Media Proposal.docx
Understanding_Digital_Forensics_Presentation.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Digital-Transformation-Roadmap-for-Companies.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation theory and applications.pdf
Approach and Philosophy of On baking technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Unlocking AI with Model Context Protocol (MCP)
Network Security Unit 5.pdf for BCA BBA.
Encapsulation_ Review paper, used for researhc scholars
Teaching material agriculture food technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The AUB Centre for AI in Media Proposal.docx

Introduction to Node.js

  • 1. Introduction to Node.js Single threaded, non-blocking, asynchronous runtime (server side Javascript)
  • 2. About me? NodeXperts? Premier Software Development Services Company. Build & Deliver for Node.js. Tremendous work in : Angular.js, D3.js, Meteor.js, ReactJs and many more.
  • 3. intro to Javascript. What the heck is an event loop?
  • 4. What is javascript? JavaScript has “event-loop”, “callback” and a stack. It is “asynchronous”, “single-threaded” and “non-blocking”. It uses v8 engine for runtime. What does it mean? Everything revolves around “event loop”.
  • 6. Stack Call? function foo2() { console.log(“hello world”); } function foo1() { foo2(); } foo1(); Stack: Finally: hello world foo2() foo1() main()
  • 7. What happen when we run code synchronously in single threaded environment? var request1 = $.getSync(‘http://xyz.com’); var request2 = $.getSync(‘http://xyz1.com’); console.log(request1); console.log(request2) What will happen? 1.request1 will process, then wait for the response. 2.Request2 will process, again wait for response. Why? Coz thread is busy processing that request.
  • 8. Then, how Javascript works asynchronously? The answer lies in event loop? What this event loop is? Let’s see...
  • 9. What is Node.js then?A server side v8 engine I hope you now have a basic idea of how javascript works on browser?
  • 10. What? Now we can run javascript on server side. Yes, it allows us to run JavaScript code in the backend, outside a browser. How? Google's V8 VM. Comes with two things: a runtime environment and a library (NPM). Sounds awesome, right?
  • 11. Features of Node Js Relies on asynchronous code to stay fast and non-blocking. Non-blocking Blocking: console.log("Hi!"); for(var i=0; i<100; i++) { console.log("Inside the loop"); } console.log("Welcome to NodeXperts.");
  • 12. Continue... Non-blocking: console.log("Hi!"); setTimeout(function timeout() { for(var i=0; i<100; i++) { console.log("Inside the loop"); } }, 5000); console.log("Welcome to NodeXperts."); Where does it go? It goes inside EVENT LOOP (through callbacks).
  • 13. Let’s take a look at an example var fs = require('fs'); fs.readFile('nx.txt', function (err, data){ if(err) throw err; console.log(data); })
  • 14. While there are events to process: e = get the next event Perform the action requested by e in thread If e’s thread is complete and there is a callback associated with e: Call the callback
  • 15. Continue... Event Loop: How it is different from browser?
  • 16. Where you can use Node Js? Few CPU cycles I/O operations Chat Applications Proxies
  • 17. Where you can not use Node Js? Heavy computation. Large and complicated web application because it doesn’t support multi-threaded programming.
  • 18. Advantages of Node Js Open source JavaScript language is used on both front-end & back-end High Scalability both Horizontally & Vertically Better Performance than traditional web servers Has a wide community of developers around the world
  • 19. Thank you Any questions? Hope you all enjoyed :)

Editor's Notes

  • #9: Show that loupe work on browser.
  • #11: More information on NPM