SlideShare a Scribd company logo
Introduction to Node.js®
Jitendra Kumar Patel
Saturday, January 31, 2015
Why node.js ?
“Node's goal is to
provide an easy
way to build
scalable Network
programs”
• Created by Ryan Dahl in 2009
• Development && maintenance sponsored by Joyent
• Licence MIT
• Last release : 0.10.31
• Based on Google V8 Engine
• +99 000 packages
About Node.js……
Success Stories…..
● Vert.x => Polygot programming
● Akka => Scala and Java
● Tornado => Python
● Libevent => C
● EventMachine => Ruby
Another project like Node.js….
● Another Web framework
● For beginner
● Multi-thread
Node.js not……
• Traditional desktop applications have a user interface wired up with
background logic
– user interfaces are based on Windows Forms, Jswing, WPF, Gtk, Qt, etc. and
dependant on operating system
• On the web user interfaces are standardized
– HTML for markup
– CSS for style
– JavaScript for dynamic content
• In the past proprietary technologies existed on the web, e.g. Adobe Flash,
ActiveX
– They are slowly dying
• Data is generated on the server, transferred to the client and displayed by
the browser
• Server Side technologies include PHP, JSP, ASP.net, Rails, Djanog, and
yes, also node.js
Development forthe Web….
● REST = REpresentational State Transfer
● Not new technology
● Architectural style for client-server
REST……
● General interface
● Scalability of component interface
● Reduce latency
● Encapsulate legacy system
Goals of REST……..
● GET
● POST
● PUT
● DELETE
HTTP Method……
● POST => Create
● GET => Read
● PUT => Update
● DELETE => Delete
HTTP Method with CRUD…..
● Non Blocking I/O
● V8 Javascript Engine
● Single Thread with Event Loop
● 40,025 modules
● Windows, Linux, Mac
● 1 Language for Frontend and Backend
● Active community
Why node.js ?
• Asynchronous i/o framework
• Core in c++ on top of v8
• Rest of it in javascript
• Swiss army knife for network Related stuffs
• Can handle thousands of Concurrent connections with Minimal
overhead (cpu/memory) on a single process
• It’s NOT a web framework, and it’s also NOT a language
What is node.js?
« A platform built on
Chrome's JavaScript runtime
for easily building fast,
scalable network
applications. »
http://nodejs.org/
• Friendly callbacks
• Ubiquitous
• No I/o Primitives
• One language to RULE them all
JavaScript is well known for client-side scripts running inside the browser
node.js is JavaScript running on the server-side
SSJS -> Server-Side JavaScript
Use a language you know
Use the same language for client side and server side
Why javascript ?!!!
JavaScript Engines……
• Perform asynchronous processing on single thread instead of classical multithread
processing, minimize overhead & latency, maximize scalability
• Scale horizontally instead of vertically
• Ideal for applications that serve a lot of requests but dont use/need lots of
computational power per request
• Not so ideal for heavy calculations, e.g. massive parallel computing
• Also: Less problems with concurrency
The idea behind node.js….
Node.js Event Loop
There are a couple of implications of this apparently very simple and basic model
• Avoid synchronous code at all costs because it blocks the event loop
• Which means: callbacks, callbacks, and more callbacks
Example :: Read data from file and show data
Blocking vs Non-Blocking……
● Read data from file
● Show data
● Do other tasks
var data = fs.readFileSync( “test.txt” );
console.log( data );
console.log( “Do other tasks” );
Blocking…..
● Read data from file
When read data completed, show data
● Do other tasks
fs.readFile( “test.txt”, function( err, data ) {
console.log(data);
});
Non-Blocking…… CallbackCallback
• Chat/Messaging
• Real-time Applications
• Intelligent Proxies
• High Concurrency Applications
• Communication Hubs
• Coordinators
When to use it ?
● Web application
● Websocket server
● Ad server
● Proxy server
● Streaming server
● Fast file upload client
● Any Real-time data apps
● Anything with high I/O
Node.js for….
• http://nodejs.org/ and Download tar.gz
• Extract to any directory
• $ ./configure && make install
Getting Started…..
Project informations
• Name
• Version
• Dependencies
• Licence
• Main file
Etc...
File package.json…..
● https://npmjs.org/
● # of modules = 1,21,943
Node.js Modules…..
$npm install <module name>
Install module…..
• var http = require(‘http’);
• var fs = require(‘fs’);
• var express = require(‘express’);
Using module…..
In NodeJS
Others modules…..
● express
● underscore
● request
● async
● mysql
Find more in npmjs.org…..
Favorite Modules…..
• IDEs for node.js
– online IDE like cloud9
– Eclipse with node.js plugins
– Visual Studio node.js Toolkit
– Jetbrains Webstorm
– lots of other IDEs: webmatrix, coderunner, Expresso, Atom, etc.
• Preferred : Jetbrains Webstorm & Visual Studio with node.js
Tools of the trade…..
http://expressjs.com
Express…
Middleware can:
• Execute any code.
• Make changes to the request and the response
objects.
• End the request-response cycle.
• Call the next middleware in the stack.
Express As Middleware
Express Middleware Modules….
● Inspire from Sinatra
● Fast
● Flexible
● Simple
Working with Express…..
• Release stable 0.10.36 (young)
• Lots of stuffs to look at
• Lots of half backed stuffs
• Retro compatibility???
• Bad at handling staticcontents
• Bad at handling binarycontents
• Hard to find organized and authoritative informations
Some Warnings…
Jitendra Kumar Patel
www.jitendrapatel.in
jitendra.patel@iiitb.org
@bewithjitendra
facebook.com/bewithjitendrapatel
Saturday, January 31, 2015
Introduction to node.js aka NodeJS

More Related Content

What's hot (20)

PPTX
Node js introduction
Joseph de Castelnau
 
PDF
Basic Understanding and Implement of Node.js
Gary Yeh
 
PDF
NodeJS ecosystem
Yukti Kaura
 
PPTX
NodeJS Concurrency
pgriess
 
PDF
Introduction to Node.js: What, why and how?
Christian Joudrey
 
PPTX
Nodejs getting started
Triet Ho
 
PDF
Understanding the Single Thread Event Loop
TorontoNodeJS
 
PDF
Node.js concurrency
Giacomo Fornari
 
PPTX
Introduction to node.js GDD
Sudar Muthu
 
KEY
OSCON 2011 - Node.js Tutorial
Tom Croucher
 
PPTX
Node js for enterprise
ravisankar munusamy
 
PPTX
Node.js, for architects - OpenSlava 2013
Oscar Renalias
 
PPTX
Java script at backend nodejs
Amit Thakkar
 
PPTX
Introduction to node.js
Arun Kumar Arjunan
 
PPTX
Introduction to Node.js
Vikash Singh
 
PPTX
Node js Introduction
sanskriti agarwal
 
PDF
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
PPTX
Introduction Node.js
Erik van Appeldoorn
 
PPTX
Node.js Patterns for Discerning Developers
cacois
 
PDF
Introduction to node js - From "hello world" to deploying on azure
Colin Mackay
 
Node js introduction
Joseph de Castelnau
 
Basic Understanding and Implement of Node.js
Gary Yeh
 
NodeJS ecosystem
Yukti Kaura
 
NodeJS Concurrency
pgriess
 
Introduction to Node.js: What, why and how?
Christian Joudrey
 
Nodejs getting started
Triet Ho
 
Understanding the Single Thread Event Loop
TorontoNodeJS
 
Node.js concurrency
Giacomo Fornari
 
Introduction to node.js GDD
Sudar Muthu
 
OSCON 2011 - Node.js Tutorial
Tom Croucher
 
Node js for enterprise
ravisankar munusamy
 
Node.js, for architects - OpenSlava 2013
Oscar Renalias
 
Java script at backend nodejs
Amit Thakkar
 
Introduction to node.js
Arun Kumar Arjunan
 
Introduction to Node.js
Vikash Singh
 
Node js Introduction
sanskriti agarwal
 
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
Introduction Node.js
Erik van Appeldoorn
 
Node.js Patterns for Discerning Developers
cacois
 
Introduction to node js - From "hello world" to deploying on azure
Colin Mackay
 

Viewers also liked (20)

KEY
Django quickstart
Marconi Moreto
 
ODP
Django tech-talk
dtdannen
 
PDF
Django Framework and Application Structure
SEONGTAEK OH
 
PDF
Building Pluggable Web Applications using Django
Lakshman Prasad
 
PPTX
An Overview of Models in Django
Michael Auritt
 
PDF
Django best practices
Adam Haney
 
PPTX
Django Framework Overview forNon-Python Developers
Rosario Renga
 
PDF
A Basic Django Introduction
Ganga Ram
 
PPTX
Django
Abhijeet Shekhar
 
PDF
2017 LSC Women's Basketball Championship Bracket
lscmedia
 
PDF
Django
Mohamed Ramadan
 
PPTX
Continuous delivery with ant and salesfroce
Rosario Renga
 
PDF
2017 LSC Men's Basketball Championship Bracket
lscmedia
 
PDF
AAPG POSTERS - Evolution of the Mardin Uplift
Joshua Doubek
 
PPTX
Apex and design pattern
Rosario Renga
 
PDF
How to Start a Movement with Your Blog - with Gideon Shalwick
Leslie Samuel
 
PPTX
Sejarah perkembangan komputer
Wahyu Dermawan
 
PDF
Extrait benchmark pratiques agiles dans les organisations
Francois Salazar
 
PDF
How to Become a Better Writer
Leslie Samuel
 
PDF
What is the most popular activity in the UK? The answer may surprise you.
Ned Potter
 
Django quickstart
Marconi Moreto
 
Django tech-talk
dtdannen
 
Django Framework and Application Structure
SEONGTAEK OH
 
Building Pluggable Web Applications using Django
Lakshman Prasad
 
An Overview of Models in Django
Michael Auritt
 
Django best practices
Adam Haney
 
Django Framework Overview forNon-Python Developers
Rosario Renga
 
A Basic Django Introduction
Ganga Ram
 
2017 LSC Women's Basketball Championship Bracket
lscmedia
 
Continuous delivery with ant and salesfroce
Rosario Renga
 
2017 LSC Men's Basketball Championship Bracket
lscmedia
 
AAPG POSTERS - Evolution of the Mardin Uplift
Joshua Doubek
 
Apex and design pattern
Rosario Renga
 
How to Start a Movement with Your Blog - with Gideon Shalwick
Leslie Samuel
 
Sejarah perkembangan komputer
Wahyu Dermawan
 
Extrait benchmark pratiques agiles dans les organisations
Francois Salazar
 
How to Become a Better Writer
Leslie Samuel
 
What is the most popular activity in the UK? The answer may surprise you.
Ned Potter
 
Ad

Similar to Introduction to node.js aka NodeJS (20)

PPT
18_Node.js.ppt
MaulikShah516542
 
PPT
18_Node.js.ppt
KhalilSalhi7
 
PDF
Tech io nodejs_20130531_v0.6
Ganesh Kondal
 
PPTX
An overview of node.js
valuebound
 
PPTX
Introduction to Node.js
AMD Developer Central
 
PDF
Introduction to Node.js
Aaron Rosenberg
 
PPTX
Nodejs
Vinod Kumar Marupu
 
PPTX
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
PPTX
Beginners Node.js
Khaled Mosharraf
 
PPTX
Proposal
Constantine Priemski
 
ODP
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
PPTX
Node js
Fatih Şimşek
 
PPTX
02 Node introduction
Ahmed Elbassel
 
PPTX
Intro to node and non blocking io
Amy Hua
 
PDF
An introduction to Node.js
Kasey McCurdy
 
PPTX
Node
Ankit Chawla
 
PPTX
Introduction to node
girish82
 
PPT
Node.js
Neethu Dasan
 
PDF
Node.js Enterprise Middleware
Behrad Zari
 
18_Node.js.ppt
MaulikShah516542
 
18_Node.js.ppt
KhalilSalhi7
 
Tech io nodejs_20130531_v0.6
Ganesh Kondal
 
An overview of node.js
valuebound
 
Introduction to Node.js
AMD Developer Central
 
Introduction to Node.js
Aaron Rosenberg
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
Beginners Node.js
Khaled Mosharraf
 
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
02 Node introduction
Ahmed Elbassel
 
Intro to node and non blocking io
Amy Hua
 
An introduction to Node.js
Kasey McCurdy
 
Introduction to node
girish82
 
Node.js
Neethu Dasan
 
Node.js Enterprise Middleware
Behrad Zari
 
Ad

More from JITENDRA KUMAR PATEL (7)

PPT
Introduction-To-SMPC-Philips-Innovation-Campus-SecurityExploded
JITENDRA KUMAR PATEL
 
PPT
Improving-The-Round-Complexity-of-VSS-in-Point-To-Point-Networks
JITENDRA KUMAR PATEL
 
PPT
Glyph-Placement-Strategy
JITENDRA KUMAR PATEL
 
PPT
Manufacturing Compromise The Emergence of Exploit-as-a-Service
JITENDRA KUMAR PATEL
 
PPT
Introduction to Web Server Security
JITENDRA KUMAR PATEL
 
ODP
Secure 2 Party AES
JITENDRA KUMAR PATEL
 
PPT
Docker meetup-jan-2015
JITENDRA KUMAR PATEL
 
Introduction-To-SMPC-Philips-Innovation-Campus-SecurityExploded
JITENDRA KUMAR PATEL
 
Improving-The-Round-Complexity-of-VSS-in-Point-To-Point-Networks
JITENDRA KUMAR PATEL
 
Glyph-Placement-Strategy
JITENDRA KUMAR PATEL
 
Manufacturing Compromise The Emergence of Exploit-as-a-Service
JITENDRA KUMAR PATEL
 
Introduction to Web Server Security
JITENDRA KUMAR PATEL
 
Secure 2 Party AES
JITENDRA KUMAR PATEL
 
Docker meetup-jan-2015
JITENDRA KUMAR PATEL
 

Recently uploaded (20)

PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
Controller Request and Response in Odoo18
Celine George
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
epi editorial commitee meeting presentation
MIPLM
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Horarios de distribución de agua en julio
pegazohn1978
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 

Introduction to node.js aka NodeJS

  • 1. Introduction to Node.js® Jitendra Kumar Patel Saturday, January 31, 2015
  • 2. Why node.js ? “Node's goal is to provide an easy way to build scalable Network programs”
  • 3. • Created by Ryan Dahl in 2009 • Development && maintenance sponsored by Joyent • Licence MIT • Last release : 0.10.31 • Based on Google V8 Engine • +99 000 packages About Node.js……
  • 5. ● Vert.x => Polygot programming ● Akka => Scala and Java ● Tornado => Python ● Libevent => C ● EventMachine => Ruby Another project like Node.js….
  • 6. ● Another Web framework ● For beginner ● Multi-thread Node.js not……
  • 7. • Traditional desktop applications have a user interface wired up with background logic – user interfaces are based on Windows Forms, Jswing, WPF, Gtk, Qt, etc. and dependant on operating system • On the web user interfaces are standardized – HTML for markup – CSS for style – JavaScript for dynamic content • In the past proprietary technologies existed on the web, e.g. Adobe Flash, ActiveX – They are slowly dying • Data is generated on the server, transferred to the client and displayed by the browser • Server Side technologies include PHP, JSP, ASP.net, Rails, Djanog, and yes, also node.js Development forthe Web….
  • 8. ● REST = REpresentational State Transfer ● Not new technology ● Architectural style for client-server REST……
  • 9. ● General interface ● Scalability of component interface ● Reduce latency ● Encapsulate legacy system Goals of REST……..
  • 10. ● GET ● POST ● PUT ● DELETE HTTP Method……
  • 11. ● POST => Create ● GET => Read ● PUT => Update ● DELETE => Delete HTTP Method with CRUD…..
  • 12. ● Non Blocking I/O ● V8 Javascript Engine ● Single Thread with Event Loop ● 40,025 modules ● Windows, Linux, Mac ● 1 Language for Frontend and Backend ● Active community Why node.js ?
  • 13. • Asynchronous i/o framework • Core in c++ on top of v8 • Rest of it in javascript • Swiss army knife for network Related stuffs • Can handle thousands of Concurrent connections with Minimal overhead (cpu/memory) on a single process • It’s NOT a web framework, and it’s also NOT a language What is node.js? « A platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. » http://nodejs.org/
  • 14. • Friendly callbacks • Ubiquitous • No I/o Primitives • One language to RULE them all JavaScript is well known for client-side scripts running inside the browser node.js is JavaScript running on the server-side SSJS -> Server-Side JavaScript Use a language you know Use the same language for client side and server side Why javascript ?!!!
  • 16. • Perform asynchronous processing on single thread instead of classical multithread processing, minimize overhead & latency, maximize scalability • Scale horizontally instead of vertically • Ideal for applications that serve a lot of requests but dont use/need lots of computational power per request • Not so ideal for heavy calculations, e.g. massive parallel computing • Also: Less problems with concurrency The idea behind node.js….
  • 17. Node.js Event Loop There are a couple of implications of this apparently very simple and basic model • Avoid synchronous code at all costs because it blocks the event loop • Which means: callbacks, callbacks, and more callbacks
  • 18. Example :: Read data from file and show data Blocking vs Non-Blocking……
  • 19. ● Read data from file ● Show data ● Do other tasks var data = fs.readFileSync( “test.txt” ); console.log( data ); console.log( “Do other tasks” ); Blocking…..
  • 20. ● Read data from file When read data completed, show data ● Do other tasks fs.readFile( “test.txt”, function( err, data ) { console.log(data); }); Non-Blocking…… CallbackCallback
  • 21. • Chat/Messaging • Real-time Applications • Intelligent Proxies • High Concurrency Applications • Communication Hubs • Coordinators When to use it ?
  • 22. ● Web application ● Websocket server ● Ad server ● Proxy server ● Streaming server ● Fast file upload client ● Any Real-time data apps ● Anything with high I/O Node.js for….
  • 23. • http://nodejs.org/ and Download tar.gz • Extract to any directory • $ ./configure && make install Getting Started…..
  • 24. Project informations • Name • Version • Dependencies • Licence • Main file Etc... File package.json…..
  • 26. $npm install <module name> Install module…..
  • 27. • var http = require(‘http’); • var fs = require(‘fs’); • var express = require(‘express’); Using module…..
  • 30. ● express ● underscore ● request ● async ● mysql Find more in npmjs.org….. Favorite Modules…..
  • 31. • IDEs for node.js – online IDE like cloud9 – Eclipse with node.js plugins – Visual Studio node.js Toolkit – Jetbrains Webstorm – lots of other IDEs: webmatrix, coderunner, Expresso, Atom, etc. • Preferred : Jetbrains Webstorm & Visual Studio with node.js Tools of the trade…..
  • 33. Middleware can: • Execute any code. • Make changes to the request and the response objects. • End the request-response cycle. • Call the next middleware in the stack. Express As Middleware
  • 35. ● Inspire from Sinatra ● Fast ● Flexible ● Simple Working with Express…..
  • 36. • Release stable 0.10.36 (young) • Lots of stuffs to look at • Lots of half backed stuffs • Retro compatibility??? • Bad at handling staticcontents • Bad at handling binarycontents • Hard to find organized and authoritative informations Some Warnings…