SlideShare a Scribd company logo
Rami Sayar -@ramisayar 
Technical Evangelist 
Microsoft Canada
•Node.js Basics and Environment 
•Node Package Manager Overview 
•Web Framework Express Basics 
•WebSocketsand Socket.io basics 
•Building a Chatroom using Node.js
•Working knowledge of JavaScript and HTML5. 
Note: Slides will be made available.
•It was created by Ryan Dahl in 2009. 
•Still considered in beta phase. 
•Latest version is v0.10.31. 
•Open-source! 
•Supports Windows, Linux, Mac OSX
Node.js is a runtime environment and library for running JavaScript applications outside the browser. 
Node.js is mostly used to run real-time server applications and shines through its performance using non-blocking I/O and asynchronous events.
•Node is great for streaming or event-based real-time applications like: 
•Chat Applications 
•Dashboards 
•Game Servers 
•Ad Servers 
•Streaming Servers 
•Online games, collaboration tools or anything meant to be real-time. 
•Node is great for when you need high levels of concurrency but little dedicated CPU time. 
•Great for writing JavaScript code everywhere!
•Microsoft 
•Yahoo! 
•LinkedIn 
•eBay 
•Dow Jones 
•Cloud9 
•The New York Times, etc…
•Five years after its debut, Node is the third most popular project onGitHub. 
•Over 2 million downloads per month. 
•Over 20 million downloads of v0.10x. 
•Over 81,000 modules onnpm. 
•Over 475meetupsworldwide talking about Node. 
Reference: http://strongloop.com/node-js/infographic/
aka.ms/node-101
“A programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses) or messages from other programs.” –Wikipedia
•Node provides the event loop as part of the language. 
•With Node, there is no call to start the loop. 
•The loop starts and doesn’t end until the last callback is complete. 
•Event loop is run under a single thread therefore sleep() makes everything halt.
varfs=require('fs'); 
varcontents=fs.readFileSync('package.json').toString(); 
console.log(contents);
varfs=require('fs'); 
fs.readFile('package.json',function(err,buf){ 
console.log(buf.toString()); 
});
•Event loops result in callback-style programming where you break apart a program into its underlying data flow. 
•In other words, you end up splitting your program into smaller and smaller chunks until each chuck is mapped to operation with data. 
•Why? So that you don’t freeze the event loop on long-running operations (such as disk or network I/O).
http://callbackhell.com/
•A function will return a promise for an object in the future. 
•Promises can be chained together. 
•Simplify programming of asyncsystems. 
Read More: http://spin.atomicobject.com/2012/03/14/nodejs- and-asynchronous-programming-with-promises/
step1(function(value1){ 
step2(value1,function(value2){ 
step3(value2,function(value3){ 
step4(value3,function(value4){ 
//Dosomethingwithvalue4 
}); 
}); 
}); 
}); 
Q.fcall(promisedStep1) 
.then(promisedStep2) 
.then(promisedStep3) 
.then(promisedStep4) 
.then(function(value4){ 
//Dosomethingwithvalue4 
}) 
.catch(function(error){ 
//Handleanyerrorfromallabovesteps 
}) 
.done();
•James Coglan–“Callbacks are imperative, promises are functional: Node’s biggest missed opportunity” 
•https://blog.jcoglan.com/2013/03/30/callbacks-are- imperative-promises-are-functional-nodes-biggest- missed-opportunity/
•Allows you to listen for “events” and assign functions to run when events occur. 
•Each emitter can emit different types of events. 
•The “error” event is special. 
•Read More: http://code.tutsplus.com/tutorials/using-nodes- event-module--net-35941
•Streams represent data streams such as I/O. 
•Streams can be piped together like in Unix. 
varfs=require("fs"); 
//ReadFile 
fs.createReadStream("package.json") 
//WriteFile 
.pipe(fs.createWriteStream("out.json"));
•Node.js has a simple module and dependencies loading system. 
•Unix philosophy -> Node philosophy 
•Write programs that do one thing and do it well-> Write modules that do one thing and do it well.
•Call the function “require” with the path of the file or directory containing the module you would like to load. 
•Returns a variable containing all the exported functions. 
varfs=require("fs");
•Official package manager for Node. 
•Bundled and installed automatically with the environment. 
Frequent Usage: 
•npminstall --save package_name 
•npmupdate
{ 
"name":"Node101", 
"version":"0.1.0", 
"description":"FITC Node101 Presentation Code", 
"main":"1_hello_world.js", 
"author":{ 
"name":"RamiSayar", 
"email":"" 
} 
} 
http://browsenpm.org/package.json
Most Depended Upon 
•7053underscore 
•6458async 
•5591request 
•4931lodash 
•3630commander 
•3543express 
•2708optimist 
•2634coffee-script 
https://www.npmjs.org/
•Reads package.json 
•Installs the dependencies in the local node_modulesfolder 
•In global mode, it makes a node module accessible to all. 
•Can install from a folder, tarball, web, etc… 
•Can specify devor optional dependencies.
Asyncis a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. 
async.map(['file1','file2','file3'],fs.stat,function(err,results){ 
//resultsisnowanarrayofstatsforeachfile 
}); 
async.filter(['file1','file2','file3'],fs.exists,function(results){ 
//resultsnowequalsanarrayoftheexistingfiles 
}); 
async.parallel([ 
function(){}, 
function(){} 
],callback); 
async.series([ 
function(){}, 
function(){} 
]);
Request is designed to be the simplest way possible to make http calls. It supports HTTPS, streaming and follows redirects by default. 
varrequest=require('request'); request('http://www.microsoft.com',function(error,response,body){ 
if(!error&&response.statusCode==200){ 
console.log(body); 
} 
});
•Socket.IO enables real-time bidirectional event-based communication using WebSockets. 
•Requires HTTP module. 
•Can broadcast to other sockets.
•Express is a minimal, open source and flexible node.js web app framework designed to make developing websites, web apps and APIs much easier. 
•Express helps you respond to requests with route support so that you may write responses to specific URLs. Express allows you to support multiple templatingengines to simplify generating HTML.
varexpress=require('express'); 
varapp=express(); 
app.get('/',function(req,res){ 
res.json({message:'hooray!welcometoourapi!'}); 
}); 
app.listen(process.env.PORT||8080);
•Node.js Basics and Environment 
•Node Package Manager Overview 
•Web Framework Express Basics 
•WebSocketsand Socket.io basics 
•Building a Chatroom using Node.js
Follow @ramisayar 
A chatroom for all! articles: aka.ms/node-101
©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related Content

What's hot

Building a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for DockerBuilding a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for Docker
Tomas Doran
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
Chris Cowan
 
Building with Virtual Development Environments
Building with Virtual Development EnvironmentsBuilding with Virtual Development Environments
Building with Virtual Development Environments
Oscar Merida
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
Christian Joudrey
 
Building with Virtual Development Environments
Building with Virtual Development EnvironmentsBuilding with Virtual Development Environments
Building with Virtual Development Environments
Oscar Merida
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
Jibanananda Sana
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 
ChinaNetCloud - Zabbix Monitoring System Overview
ChinaNetCloud - Zabbix Monitoring System OverviewChinaNetCloud - Zabbix Monitoring System Overview
ChinaNetCloud - Zabbix Monitoring System Overview
ChinaNetCloud
 
Node.JS and WebSockets with Faye
Node.JS and WebSockets with FayeNode.JS and WebSockets with Faye
Node.JS and WebSockets with FayeMatjaž Lipuš
 
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challengeПостроение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
OdessaFrontend
 
Dcjq node.js presentation
Dcjq node.js presentationDcjq node.js presentation
Dcjq node.js presentation
async_io
 
Vagrant & Docker
Vagrant & DockerVagrant & Docker
Building an ActionScript Game Server with over 15,000 Concurrent Connections
Building an ActionScript Game Server with over 15,000 Concurrent ConnectionsBuilding an ActionScript Game Server with over 15,000 Concurrent Connections
Building an ActionScript Game Server with over 15,000 Concurrent Connections
Renaun Erickson
 
Data Processing and Ruby in the World
Data Processing and Ruby in the WorldData Processing and Ruby in the World
Data Processing and Ruby in the World
SATOSHI TAGOMORI
 
Let's server your Data
Let's server your DataLet's server your Data
Let's server your Data
Frank van der Linden
 
Docker Container Orchestration
Docker Container OrchestrationDocker Container Orchestration
Docker Container Orchestration
Fernand Galiana
 
Node.js for beginner
Node.js for beginnerNode.js for beginner
Node.js for beginner
Sarunyhot Suwannachoti
 
Mern stack
Mern stackMern stack
Mern stack
Eduonix
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Nurul Ferdous
 

What's hot (20)

Building a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for DockerBuilding a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for Docker
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
Building with Virtual Development Environments
Building with Virtual Development EnvironmentsBuilding with Virtual Development Environments
Building with Virtual Development Environments
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
 
Building with Virtual Development Environments
Building with Virtual Development EnvironmentsBuilding with Virtual Development Environments
Building with Virtual Development Environments
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
 
ChinaNetCloud - Zabbix Monitoring System Overview
ChinaNetCloud - Zabbix Monitoring System OverviewChinaNetCloud - Zabbix Monitoring System Overview
ChinaNetCloud - Zabbix Monitoring System Overview
 
Node.JS and WebSockets with Faye
Node.JS and WebSockets with FayeNode.JS and WebSockets with Faye
Node.JS and WebSockets with Faye
 
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challengeПостроение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
 
Dcjq node.js presentation
Dcjq node.js presentationDcjq node.js presentation
Dcjq node.js presentation
 
Vagrant & Docker
Vagrant & DockerVagrant & Docker
Vagrant & Docker
 
Building an ActionScript Game Server with over 15,000 Concurrent Connections
Building an ActionScript Game Server with over 15,000 Concurrent ConnectionsBuilding an ActionScript Game Server with over 15,000 Concurrent Connections
Building an ActionScript Game Server with over 15,000 Concurrent Connections
 
Data Processing and Ruby in the World
Data Processing and Ruby in the WorldData Processing and Ruby in the World
Data Processing and Ruby in the World
 
Let's server your Data
Let's server your DataLet's server your Data
Let's server your Data
 
Docker Container Orchestration
Docker Container OrchestrationDocker Container Orchestration
Docker Container Orchestration
 
Node.js for beginner
Node.js for beginnerNode.js for beginner
Node.js for beginner
 
Mern stack
Mern stackMern stack
Mern stack
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
 

Viewers also liked

Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907
NodejsFoundation
 
Playing nice with the MEAN stack
Playing nice with the MEAN stackPlaying nice with the MEAN stack
Playing nice with the MEAN stack
Aspenware
 
Object Oriented Programing in JavaScript
Object Oriented Programing in JavaScriptObject Oriented Programing in JavaScript
Object Oriented Programing in JavaScript
Akshay Mathur
 
TypeScript 101
TypeScript 101TypeScript 101
TypeScript 101
rachelterman
 
Building Modern Web Apps with MEAN Stack
Building Modern Web Apps with MEAN StackBuilding Modern Web Apps with MEAN Stack
Building Modern Web Apps with MEAN Stack
Suresh Patidar
 
Introduction to the MEAN stack
Introduction to the MEAN stackIntroduction to the MEAN stack
Introduction to the MEAN stack
Yoann Gotthilf
 
Get MEAN! Node.js and the MEAN stack
Get MEAN!  Node.js and the MEAN stackGet MEAN!  Node.js and the MEAN stack
Get MEAN! Node.js and the MEAN stack
Nicholas McClay
 
Introduction to Modern and Emerging Web Technologies
Introduction to Modern and Emerging Web TechnologiesIntroduction to Modern and Emerging Web Technologies
Introduction to Modern and Emerging Web Technologies
Suresh Patidar
 
Starting from Scratch with the MEAN Stack
Starting from Scratch with the MEAN StackStarting from Scratch with the MEAN Stack
Starting from Scratch with the MEAN Stack
MongoDB
 
Accumulations with Nicholas Felton
Accumulations with Nicholas FeltonAccumulations with Nicholas Felton
Accumulations with Nicholas Felton
FITC
 
How We Used To, How We Will
How We Used To, How We WillHow We Used To, How We Will
How We Used To, How We Will
FITC
 
It’s the Experience That Makes the Product, Not the Features
It’s the Experience That Makes the Product, Not the FeaturesIt’s the Experience That Makes the Product, Not the Features
It’s the Experience That Makes the Product, Not the Features
FITC
 
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
FITC
 
How to SURVIVE the Creative Industry
How to SURVIVE the Creative IndustryHow to SURVIVE the Creative Industry
How to SURVIVE the Creative Industry
FITC
 
Managing The Process
Managing The ProcessManaging The Process
Managing The Process
FITC
 
Building Apps with Ember
Building Apps with EmberBuilding Apps with Ember
Building Apps with Ember
FITC
 
Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
FITC
 
Hardware for a_soft_world_bkup
Hardware for a_soft_world_bkupHardware for a_soft_world_bkup
Hardware for a_soft_world_bkup
FITC
 
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric BoydGamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
FITC
 
When Clients Bare it All with David Allen
When Clients Bare it All with David AllenWhen Clients Bare it All with David Allen
When Clients Bare it All with David Allen
FITC
 

Viewers also liked (20)

Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907
 
Playing nice with the MEAN stack
Playing nice with the MEAN stackPlaying nice with the MEAN stack
Playing nice with the MEAN stack
 
Object Oriented Programing in JavaScript
Object Oriented Programing in JavaScriptObject Oriented Programing in JavaScript
Object Oriented Programing in JavaScript
 
TypeScript 101
TypeScript 101TypeScript 101
TypeScript 101
 
Building Modern Web Apps with MEAN Stack
Building Modern Web Apps with MEAN StackBuilding Modern Web Apps with MEAN Stack
Building Modern Web Apps with MEAN Stack
 
Introduction to the MEAN stack
Introduction to the MEAN stackIntroduction to the MEAN stack
Introduction to the MEAN stack
 
Get MEAN! Node.js and the MEAN stack
Get MEAN!  Node.js and the MEAN stackGet MEAN!  Node.js and the MEAN stack
Get MEAN! Node.js and the MEAN stack
 
Introduction to Modern and Emerging Web Technologies
Introduction to Modern and Emerging Web TechnologiesIntroduction to Modern and Emerging Web Technologies
Introduction to Modern and Emerging Web Technologies
 
Starting from Scratch with the MEAN Stack
Starting from Scratch with the MEAN StackStarting from Scratch with the MEAN Stack
Starting from Scratch with the MEAN Stack
 
Accumulations with Nicholas Felton
Accumulations with Nicholas FeltonAccumulations with Nicholas Felton
Accumulations with Nicholas Felton
 
How We Used To, How We Will
How We Used To, How We WillHow We Used To, How We Will
How We Used To, How We Will
 
It’s the Experience That Makes the Product, Not the Features
It’s the Experience That Makes the Product, Not the FeaturesIt’s the Experience That Makes the Product, Not the Features
It’s the Experience That Makes the Product, Not the Features
 
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
 
How to SURVIVE the Creative Industry
How to SURVIVE the Creative IndustryHow to SURVIVE the Creative Industry
How to SURVIVE the Creative Industry
 
Managing The Process
Managing The ProcessManaging The Process
Managing The Process
 
Building Apps with Ember
Building Apps with EmberBuilding Apps with Ember
Building Apps with Ember
 
Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
 
Hardware for a_soft_world_bkup
Hardware for a_soft_world_bkupHardware for a_soft_world_bkup
Hardware for a_soft_world_bkup
 
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric BoydGamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
 
When Clients Bare it All with David Allen
When Clients Bare it All with David AllenWhen Clients Bare it All with David Allen
When Clients Bare it All with David Allen
 

Similar to Node.js 101 with Rami Sayar

FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
Rami Sayar
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
Felix Geisendörfer
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013
timfox111
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
Lucas Jellema
 
Node.js: The What, The How and The When
Node.js: The What, The How and The WhenNode.js: The What, The How and The When
Node.js: The What, The How and The When
FITC
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
Nir Noy
 
Node.js Introduction
Node.js IntroductionNode.js Introduction
Node.js Introduction
Kelum Senanayake
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)
Lucas Jellema
 
Nodejs
NodejsNodejs
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
David Padbury
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
Colin Mackay
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
cacois
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
Khaled Mosharraf
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
Sasha Goldshtein
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
async_io
 
Node.js Chapter1
Node.js Chapter1Node.js Chapter1
Node.js Chapter1
Talentica Software
 

Similar to Node.js 101 with Rami Sayar (20)

FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
 
Node.js: The What, The How and The When
Node.js: The What, The How and The WhenNode.js: The What, The How and The When
Node.js: The What, The How and The When
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
 
Node.js Introduction
Node.js IntroductionNode.js Introduction
Node.js Introduction
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)
 
Nodejs
NodejsNodejs
Nodejs
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Node js beginner
Node js beginnerNode js beginner
Node js beginner
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Node.js Chapter1
Node.js Chapter1Node.js Chapter1
Node.js Chapter1
 

More from FITC

Cut it up
Cut it upCut it up
Cut it up
FITC
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
FITC
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
FITC
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
FITC
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
FITC
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
FITC
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
FITC
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
FITC
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
FITC
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
FITC
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
FITC
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
FITC
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
FITC
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
FITC
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
FITC
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
FITC
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
FITC
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
FITC
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
FITC
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
FITC
 

More from FITC (20)

Cut it up
Cut it upCut it up
Cut it up
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
 

Recently uploaded

Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
TristanJasperRamos
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
Himani415946
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
ShahulHameed54211
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 

Recently uploaded (16)

Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 

Node.js 101 with Rami Sayar

  • 1. Rami Sayar -@ramisayar Technical Evangelist Microsoft Canada
  • 2. •Node.js Basics and Environment •Node Package Manager Overview •Web Framework Express Basics •WebSocketsand Socket.io basics •Building a Chatroom using Node.js
  • 3. •Working knowledge of JavaScript and HTML5. Note: Slides will be made available.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. •It was created by Ryan Dahl in 2009. •Still considered in beta phase. •Latest version is v0.10.31. •Open-source! •Supports Windows, Linux, Mac OSX
  • 11. Node.js is a runtime environment and library for running JavaScript applications outside the browser. Node.js is mostly used to run real-time server applications and shines through its performance using non-blocking I/O and asynchronous events.
  • 12. •Node is great for streaming or event-based real-time applications like: •Chat Applications •Dashboards •Game Servers •Ad Servers •Streaming Servers •Online games, collaboration tools or anything meant to be real-time. •Node is great for when you need high levels of concurrency but little dedicated CPU time. •Great for writing JavaScript code everywhere!
  • 13. •Microsoft •Yahoo! •LinkedIn •eBay •Dow Jones •Cloud9 •The New York Times, etc…
  • 14. •Five years after its debut, Node is the third most popular project onGitHub. •Over 2 million downloads per month. •Over 20 million downloads of v0.10x. •Over 81,000 modules onnpm. •Over 475meetupsworldwide talking about Node. Reference: http://strongloop.com/node-js/infographic/
  • 16.
  • 17.
  • 18. “A programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses) or messages from other programs.” –Wikipedia
  • 19. •Node provides the event loop as part of the language. •With Node, there is no call to start the loop. •The loop starts and doesn’t end until the last callback is complete. •Event loop is run under a single thread therefore sleep() makes everything halt.
  • 22. •Event loops result in callback-style programming where you break apart a program into its underlying data flow. •In other words, you end up splitting your program into smaller and smaller chunks until each chuck is mapped to operation with data. •Why? So that you don’t freeze the event loop on long-running operations (such as disk or network I/O).
  • 24. •A function will return a promise for an object in the future. •Promises can be chained together. •Simplify programming of asyncsystems. Read More: http://spin.atomicobject.com/2012/03/14/nodejs- and-asynchronous-programming-with-promises/
  • 25. step1(function(value1){ step2(value1,function(value2){ step3(value2,function(value3){ step4(value3,function(value4){ //Dosomethingwithvalue4 }); }); }); }); Q.fcall(promisedStep1) .then(promisedStep2) .then(promisedStep3) .then(promisedStep4) .then(function(value4){ //Dosomethingwithvalue4 }) .catch(function(error){ //Handleanyerrorfromallabovesteps }) .done();
  • 26. •James Coglan–“Callbacks are imperative, promises are functional: Node’s biggest missed opportunity” •https://blog.jcoglan.com/2013/03/30/callbacks-are- imperative-promises-are-functional-nodes-biggest- missed-opportunity/
  • 27.
  • 28. •Allows you to listen for “events” and assign functions to run when events occur. •Each emitter can emit different types of events. •The “error” event is special. •Read More: http://code.tutsplus.com/tutorials/using-nodes- event-module--net-35941
  • 29. •Streams represent data streams such as I/O. •Streams can be piped together like in Unix. varfs=require("fs"); //ReadFile fs.createReadStream("package.json") //WriteFile .pipe(fs.createWriteStream("out.json"));
  • 30. •Node.js has a simple module and dependencies loading system. •Unix philosophy -> Node philosophy •Write programs that do one thing and do it well-> Write modules that do one thing and do it well.
  • 31. •Call the function “require” with the path of the file or directory containing the module you would like to load. •Returns a variable containing all the exported functions. varfs=require("fs");
  • 32. •Official package manager for Node. •Bundled and installed automatically with the environment. Frequent Usage: •npminstall --save package_name •npmupdate
  • 33. { "name":"Node101", "version":"0.1.0", "description":"FITC Node101 Presentation Code", "main":"1_hello_world.js", "author":{ "name":"RamiSayar", "email":"" } } http://browsenpm.org/package.json
  • 34. Most Depended Upon •7053underscore •6458async •5591request •4931lodash •3630commander •3543express •2708optimist •2634coffee-script https://www.npmjs.org/
  • 35. •Reads package.json •Installs the dependencies in the local node_modulesfolder •In global mode, it makes a node module accessible to all. •Can install from a folder, tarball, web, etc… •Can specify devor optional dependencies.
  • 36. Asyncis a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. async.map(['file1','file2','file3'],fs.stat,function(err,results){ //resultsisnowanarrayofstatsforeachfile }); async.filter(['file1','file2','file3'],fs.exists,function(results){ //resultsnowequalsanarrayoftheexistingfiles }); async.parallel([ function(){}, function(){} ],callback); async.series([ function(){}, function(){} ]);
  • 37. Request is designed to be the simplest way possible to make http calls. It supports HTTPS, streaming and follows redirects by default. varrequest=require('request'); request('http://www.microsoft.com',function(error,response,body){ if(!error&&response.statusCode==200){ console.log(body); } });
  • 38. •Socket.IO enables real-time bidirectional event-based communication using WebSockets. •Requires HTTP module. •Can broadcast to other sockets.
  • 39. •Express is a minimal, open source and flexible node.js web app framework designed to make developing websites, web apps and APIs much easier. •Express helps you respond to requests with route support so that you may write responses to specific URLs. Express allows you to support multiple templatingengines to simplify generating HTML.
  • 40. varexpress=require('express'); varapp=express(); app.get('/',function(req,res){ res.json({message:'hooray!welcometoourapi!'}); }); app.listen(process.env.PORT||8080);
  • 41.
  • 42.
  • 43. •Node.js Basics and Environment •Node Package Manager Overview •Web Framework Express Basics •WebSocketsand Socket.io basics •Building a Chatroom using Node.js
  • 44. Follow @ramisayar A chatroom for all! articles: aka.ms/node-101
  • 45. ©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.