SlideShare a Scribd company logo
Node.js
Awesome, Lightweight, JavaScript, High Performance

qr.net/fitc2014
WHO AM I?
•

Richard Nieuwenhuis

•

32 years old

•

MediaMonks

•

7 years a Monk

•

Lead of Operations / Head of
development
Overview
•

What is Node.js

•

Some small examples

•

Asynchrony here, asynchrony there

•

Some (popular) Node.js modules

•

Socket.io

•

High performance examples

•

Some tips & tricks
When and by whom?
•

First made public in 2009

•

Ryan Lienhart Dahl

•

Currently at version 0.10.25*

•

“Why is a progress bar so difficult?”
•

•

“Why the heck are we polling???”
This sheet was created 17-2-2014
What nodejs.org says
•

“Node.js is a platform built on Chrome's JavaScript runtime for
easily building fast, scalable network applications. Node.js uses
an event-driven, non-blocking I/O model that makes it lightweight
and efficient, perfect for data-intensive real-time applications that
run across distributed devices.”
In short how many people see it

•

Server side JavaScript!
High Level Component overview

Node.js

V8

Event Loop
(Libuv)
Where to begin?
•

Download & Install Node.js
•

•

Use your favorite IDE

Node.js API/Modules:
•
•

Sort of API‟s which expose Node functions

•

Allows the Node.js community to extend Node.js

•
•

Built-in

Super lightweight

Add-ons
•

Quite a big community

•

The NPM (Node Package Manager)
Some Node.js APIs/Modules
•

http
•

•

Provides basic functions for creating a server and handling requests

https
•

•

For setting up a secured server
assert

•
•

For creating unit tests for your code (NodeTDD!)
fs

•

For doing stuff with the File System
Some Node.js
APIs/Modules continued
•

querystring
•

•

For parsing the query string of a request
url

•
•

functions for parsing and resolving URL‟s
repl: Read-Eval-Print-Loop

•

Good for debugging and testing
Let‟s build something simple
•

Simple server
•

Every “Hello World” Example starts with this.

•

Read the files of a folder.

•

Print the file names in the browser in sorted fashion.

•

PS. Examples show Node specifics and are to illustrate points and are by no
means “elegant, save” etc :-)
Create our own module: sorterservice.js
function sortFileNames(fileNames){
return fileNames.sort();
}

exports.sortFileNames = sortFileNames;

-

a module can be a single file
a module can be a folder
exports is a special object to define properties

-

Can be any type: function, strings, etc
Requiring needed modules
//require the needed modules
var http = require('http');
var fs

= require('fs');

var sorter = require('./sorterservice');
Create server and verify requests
http.createServer(function(req, res){
switch(req.method){
case 'POST':
console.log('This is a post request');
break;
case 'GET':
switch(req.url){
case '/':
readFileNames(res);
break;
case '/showfiles„:
readFileNames(res);
break;
case '/favicon.ico„:
break;
}
break;
default:
res.setHeader('Content-Type', 'text/plain');
res.end("This method I simply do not know");
}
Let‟s read the file names
function readFileNames(res){
var dirName = './files';

var html = '';
var fileNames

= fs.readdirSync(dirName);

var sortedFileNames = sorter.sortFileNames(fileNames);
html += '<ol>';
for(var index in sortedFileNames){
html += '<li>' + sortedFileNames[index] + '</li>';
}
html += '</ol>';
sendFileNames(res, html);
}
One last thing & Does it work?

function sendFileNames(res, html){
res.setHeader('Content-Type', 'text/html');
res.end(html);
}
Two big things not OK here
Which are also two important Node aspects

1)

Error handling

2)

A-synchronous architecture
Main problem 1
function readFileNames(res){
var dirName = './files';
var html = '';

var fileNames = [];
fileNames

= fs.readdirSync(dirName);

var sortedFileNames = sorter.sortFileNames(fileNames);
html += '<ol>';
for(var index in sortedFileNames){
html += '<li>' + sortedFileNames[index] + '</li>';
}

html += '</ol>';
sendFileNames(res, html);
}
What did we see?
•

The server crashed and Node stopped running

•

A lot less forgiving than PHP for example

•

Not OK during a super bowl commercial where millions of Dollars are spend
;-)

Tip: Look at the Node.js module forever
In this case a simple
if (fs.existsSync(dirName)){
fileNames = fs.readdirSync(dirName);
}

Would suffice….
•

Defensive programming is super important in Node
•

Verify everything!

•

Valid user input

•

Expect the unexpected (even if you expect otherwise)

•

Act on any error that may occur (and log it)

•

Have a process in place to restart node just to be sure (forever module)
“Problemo” numero dos
fs.readdirSync(dirName);

Node is a single threaded running process.
Synchronous development
•

Blocking/Synchronous requests are bad

•
•

It will “block” the continuation of your logic for the amount of time the
blocking request is active (requesting a JSON file for example)

On the server you basically have the same problems

•
•

But it will affect all visitors immediately when one request is stalling
Can ultimately lead to a crashing server
Synchronous development
http.createServer(function(req, res){
switch(req.method){

case 'POST':
console.log('This is a post request');
break;

case 'GET':
//”Select *” all 200K users from the database
//Give it back to the response

}
}).listen(8888);
Continued
Pffff, I need to
return 200K
rows?

Request

Cpu to r2: Sorry, I
am doing nothing,
but the DB is
sooooo slowww

Request 2

Going to take
me a while!

doQuery()

CPU

processData()

Cpu
time

DB
The Event Loop
Take this event
loop!:
doQuery(cb)

Pffff, I need to
return 200K
rows?
Going to take me
a while!

Request

CPU to r2: thanks
man! I am
processing your
request

Request 2

CPU

processData()

E
loop

callback

DB
A-Synchronous Node development

A lot of Node functions have a-synchronous versions.
fs.readdir(dirName, function(err, data){

if (err){

console.log();
}
var sortedFileNames = sorter.sortFileNames(data);
//The other code
--------------------------http.createServer(function(req, res){……
A-Synchronous Node development
•

A-synchronize as much as possible to keep the main process as “free” as
possible.

•

•

Much more necessary when it is a high-performance environment

It is not the holy grail! Keep the Big O in mind: for (var x = 0; x < 25.5Billion;
x++)

•

Sequencing & parallel

•

Can become quite messy and unreadable
A highly unlikely hypothetical situation

•

Read the files from Dir A

•

Merge the content of all files of Dir A into one file

•

Read the files from Dir B

•

Append the content of step 1 to all files in Dir B

•

Store these results in the Database
Would look something like this
aSynReadDir('A/', function(files) {

mergeFiles(files, function(fileContents) {
aSynReadDir('B/', function(files) {
appendFiles(fileContents, files, function(appendedFiles) {

insertIntoDatabase(appendedFiles, function() {
});
});
});
});
});
Useful Node Modules: Socket.io
•

Latest browsers support Web sockets
•

IE10+

•

Chrome

•

FireFox

•

“Weirdly” on Android only starting from 4.4…

•

Socket.io leverages the Web socket technology for bi-directional
communication between clients & servers:

•

With degradability in place for the “older” browsers!
Socket.io continued
•

Very nice for real time applications with a lot of concurrent users.
•

Browser based games where you mobile is the controller

•

Second screen applications

•

Updating the client:

•

Chat

•

Real time statistics

•

News updates

•

Etc
Small example (Server)
var server = http.createServer(function(req, res){
//code here
});
var io = socketio.listen(server);
function sendRandomMessage(){
var index = Math.floor((Math.random()*4));
io.sockets.send(words[index]);
}
Small example (Client)
var socket = io.connect();
socket.on('message', function (message) {
console.log(„I received the message ' + message);
var m = document.createElement('p');
m.innerText = message;

document.getElementById('text').appendChild(m);
});
Event Listener
socket.on('message', function (message)……

socket.emit(„fired‟, {message: yep, you are fired});
Other Useful Node Modules
"dependencies": {
"express": "3.4.7", // Web Framework
"express-validator": "1.0.1",
"request": "2.25.0", //
"redis": "0.10.0", //Redis: High performance in memory DB
"hiredis": "0.1.16", // To make Redis even faster with C written stuff
"redis-sentinel": "0.0.5", // Redis failover
"http-auth": "*", //for authentication
"openid": "0.5.5", //Open ID client
"statsd-client": "*", //NodeJS deamon for logging request s
tatistics
"facebook-node-sdk": "0.2.0",
"librato-metrics": "0.0.7",
"statsd-client": "0.0.15"
}
ADIDAS
NITROCHARGE

An interactive cinematic
experience using your mobile
phone as a controller.

Produced for DDB & Tribal

Case
Video
KLM
CLAIM YOUR
PLACE IN SPACE

Are you ready to win the ultimate journey
of inspiration? Claim your spot in space

Produced for DDB & Tribal Amsterdam

Case
Video
THE VOICE
OF HOLLAND
Talpa

This season you can be a
coach at home. Show your
coaching qualities with The
Voice of Holland Thuiscoach
app.

Case
Video
THANK YOU!
•

We are looking for new awesome
developers!

•

Questions: richard@mediamonks.com

More Related Content

What's hot

Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
cacois
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
Tom Croucher
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)
Felix Geisendörfer
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
Aarti Parikh
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
Gary Yeh
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
Felix Geisendörfer
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
Ganesh Kondal
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRichard Lee
 
Node.js Explained
Node.js ExplainedNode.js Explained
Node.js Explained
Jeff Kunkle
 
node.js dao
node.js daonode.js dao
node.js dao
Vladimir Miguro
 
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Binary Studio
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleTom Croucher
 
Introduction to Node.js: perspectives from a Drupal dev
Introduction to Node.js: perspectives from a Drupal devIntroduction to Node.js: perspectives from a Drupal dev
Introduction to Node.js: perspectives from a Drupal dev
mcantelon
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
Felix Geisendörfer
 
Rapid API development examples for Impress Application Server / Node.js (jsfw...
Rapid API development examples for Impress Application Server / Node.js (jsfw...Rapid API development examples for Impress Application Server / Node.js (jsfw...
Rapid API development examples for Impress Application Server / Node.js (jsfw...
Timur Shemsedinov
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
zeeg
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
Hüseyin BABAL
 
Node.js - As a networking tool
Node.js - As a networking toolNode.js - As a networking tool
Node.js - As a networking tool
Felix Geisendörfer
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
 

What's hot (20)

Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
 
Node.js
Node.jsNode.js
Node.js
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node.js Explained
Node.js ExplainedNode.js Explained
Node.js Explained
 
node.js dao
node.js daonode.js dao
node.js dao
 
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scale
 
Introduction to Node.js: perspectives from a Drupal dev
Introduction to Node.js: perspectives from a Drupal devIntroduction to Node.js: perspectives from a Drupal dev
Introduction to Node.js: perspectives from a Drupal dev
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
 
Rapid API development examples for Impress Application Server / Node.js (jsfw...
Rapid API development examples for Impress Application Server / Node.js (jsfw...Rapid API development examples for Impress Application Server / Node.js (jsfw...
Rapid API development examples for Impress Application Server / Node.js (jsfw...
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
Node.js - As a networking tool
Node.js - As a networking toolNode.js - As a networking tool
Node.js - As a networking tool
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 

Viewers also liked

Future of modernization
Future of modernizationFuture of modernization
Future of modernization
Mechelle Davidson
 
It’s Not Enough To Be Brilliant – You Have To Be Convincing, Too. with Lanny...
 It’s Not Enough To Be Brilliant – You Have To Be Convincing, Too. with Lanny... It’s Not Enough To Be Brilliant – You Have To Be Convincing, Too. with Lanny...
It’s Not Enough To Be Brilliant – You Have To Be Convincing, Too. with Lanny...
FITC
 
高性能Javascript
高性能Javascript高性能Javascript
高性能Javascriptfangdeng
 
High performance java script why everything youve been taught is wrong
High performance java script why everything youve been taught is wrongHigh performance java script why everything youve been taught is wrong
High performance java script why everything youve been taught is wrong
Tao Gao
 
Change mind about JS
Change mind about JSChange mind about JS
Change mind about JS
Damien Simonin Feugas
 
Sais-tu que...
Sais-tu que...Sais-tu que...
Sais-tu que...
forever22
 
Business Aspects of High Performance Websites
Business Aspects of High Performance WebsitesBusiness Aspects of High Performance Websites
Business Aspects of High Performance Websitesmalteubl
 

Viewers also liked (7)

Future of modernization
Future of modernizationFuture of modernization
Future of modernization
 
It’s Not Enough To Be Brilliant – You Have To Be Convincing, Too. with Lanny...
 It’s Not Enough To Be Brilliant – You Have To Be Convincing, Too. with Lanny... It’s Not Enough To Be Brilliant – You Have To Be Convincing, Too. with Lanny...
It’s Not Enough To Be Brilliant – You Have To Be Convincing, Too. with Lanny...
 
高性能Javascript
高性能Javascript高性能Javascript
高性能Javascript
 
High performance java script why everything youve been taught is wrong
High performance java script why everything youve been taught is wrongHigh performance java script why everything youve been taught is wrong
High performance java script why everything youve been taught is wrong
 
Change mind about JS
Change mind about JSChange mind about JS
Change mind about JS
 
Sais-tu que...
Sais-tu que...Sais-tu que...
Sais-tu que...
 
Business Aspects of High Performance Websites
Business Aspects of High Performance WebsitesBusiness Aspects of High Performance Websites
Business Aspects of High Performance Websites
 

Similar to Node.js: The What, The How and The When

Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
Felix Geisendörfer
 
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
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
Rami Sayar
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
FITC
 
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
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
Gonzalo Ayuso
 
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
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
Derek Anderson
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
soft-shake.ch
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
Sudar Muthu
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
Node.js
Node.jsNode.js
Node.js
Ian Oxley
 
5.node js
5.node js5.node js
5.node js
Geunhyung Kim
 
node_js.pptx
node_js.pptxnode_js.pptx
node_js.pptx
dipen55
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
Yoann Gotthilf
 

Similar to Node.js: The What, The How and The When (20)

Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
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
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
 
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?
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
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
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Node.js
Node.jsNode.js
Node.js
 
Node.js
Node.jsNode.js
Node.js
 
5.node js
5.node js5.node js
5.node js
 
node_js.pptx
node_js.pptxnode_js.pptx
node_js.pptx
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
 

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

Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 

Recently uploaded (20)

Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 

Node.js: The What, The How and The When

  • 1. Node.js Awesome, Lightweight, JavaScript, High Performance qr.net/fitc2014
  • 2. WHO AM I? • Richard Nieuwenhuis • 32 years old • MediaMonks • 7 years a Monk • Lead of Operations / Head of development
  • 3.
  • 4. Overview • What is Node.js • Some small examples • Asynchrony here, asynchrony there • Some (popular) Node.js modules • Socket.io • High performance examples • Some tips & tricks
  • 5. When and by whom? • First made public in 2009 • Ryan Lienhart Dahl • Currently at version 0.10.25* • “Why is a progress bar so difficult?” • • “Why the heck are we polling???” This sheet was created 17-2-2014
  • 6. What nodejs.org says • “Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  • 7. In short how many people see it • Server side JavaScript!
  • 8. High Level Component overview Node.js V8 Event Loop (Libuv)
  • 9. Where to begin? • Download & Install Node.js • • Use your favorite IDE Node.js API/Modules: • • Sort of API‟s which expose Node functions • Allows the Node.js community to extend Node.js • • Built-in Super lightweight Add-ons • Quite a big community • The NPM (Node Package Manager)
  • 10. Some Node.js APIs/Modules • http • • Provides basic functions for creating a server and handling requests https • • For setting up a secured server assert • • For creating unit tests for your code (NodeTDD!) fs • For doing stuff with the File System
  • 11. Some Node.js APIs/Modules continued • querystring • • For parsing the query string of a request url • • functions for parsing and resolving URL‟s repl: Read-Eval-Print-Loop • Good for debugging and testing
  • 12. Let‟s build something simple • Simple server • Every “Hello World” Example starts with this. • Read the files of a folder. • Print the file names in the browser in sorted fashion. • PS. Examples show Node specifics and are to illustrate points and are by no means “elegant, save” etc :-)
  • 13. Create our own module: sorterservice.js function sortFileNames(fileNames){ return fileNames.sort(); } exports.sortFileNames = sortFileNames; - a module can be a single file a module can be a folder exports is a special object to define properties - Can be any type: function, strings, etc
  • 14. Requiring needed modules //require the needed modules var http = require('http'); var fs = require('fs'); var sorter = require('./sorterservice');
  • 15. Create server and verify requests http.createServer(function(req, res){ switch(req.method){ case 'POST': console.log('This is a post request'); break; case 'GET': switch(req.url){ case '/': readFileNames(res); break; case '/showfiles„: readFileNames(res); break; case '/favicon.ico„: break; } break; default: res.setHeader('Content-Type', 'text/plain'); res.end("This method I simply do not know"); }
  • 16. Let‟s read the file names function readFileNames(res){ var dirName = './files'; var html = ''; var fileNames = fs.readdirSync(dirName); var sortedFileNames = sorter.sortFileNames(fileNames); html += '<ol>'; for(var index in sortedFileNames){ html += '<li>' + sortedFileNames[index] + '</li>'; } html += '</ol>'; sendFileNames(res, html); }
  • 17. One last thing & Does it work? function sendFileNames(res, html){ res.setHeader('Content-Type', 'text/html'); res.end(html); }
  • 18. Two big things not OK here Which are also two important Node aspects 1) Error handling 2) A-synchronous architecture
  • 19. Main problem 1 function readFileNames(res){ var dirName = './files'; var html = ''; var fileNames = []; fileNames = fs.readdirSync(dirName); var sortedFileNames = sorter.sortFileNames(fileNames); html += '<ol>'; for(var index in sortedFileNames){ html += '<li>' + sortedFileNames[index] + '</li>'; } html += '</ol>'; sendFileNames(res, html); }
  • 20. What did we see? • The server crashed and Node stopped running • A lot less forgiving than PHP for example • Not OK during a super bowl commercial where millions of Dollars are spend ;-) Tip: Look at the Node.js module forever
  • 21. In this case a simple if (fs.existsSync(dirName)){ fileNames = fs.readdirSync(dirName); } Would suffice…. • Defensive programming is super important in Node • Verify everything! • Valid user input • Expect the unexpected (even if you expect otherwise) • Act on any error that may occur (and log it) • Have a process in place to restart node just to be sure (forever module)
  • 22. “Problemo” numero dos fs.readdirSync(dirName); Node is a single threaded running process.
  • 23. Synchronous development • Blocking/Synchronous requests are bad • • It will “block” the continuation of your logic for the amount of time the blocking request is active (requesting a JSON file for example) On the server you basically have the same problems • • But it will affect all visitors immediately when one request is stalling Can ultimately lead to a crashing server
  • 24. Synchronous development http.createServer(function(req, res){ switch(req.method){ case 'POST': console.log('This is a post request'); break; case 'GET': //”Select *” all 200K users from the database //Give it back to the response } }).listen(8888);
  • 25. Continued Pffff, I need to return 200K rows? Request Cpu to r2: Sorry, I am doing nothing, but the DB is sooooo slowww Request 2 Going to take me a while! doQuery() CPU processData() Cpu time DB
  • 26. The Event Loop Take this event loop!: doQuery(cb) Pffff, I need to return 200K rows? Going to take me a while! Request CPU to r2: thanks man! I am processing your request Request 2 CPU processData() E loop callback DB
  • 27. A-Synchronous Node development A lot of Node functions have a-synchronous versions. fs.readdir(dirName, function(err, data){ if (err){ console.log(); } var sortedFileNames = sorter.sortFileNames(data); //The other code --------------------------http.createServer(function(req, res){……
  • 28. A-Synchronous Node development • A-synchronize as much as possible to keep the main process as “free” as possible. • • Much more necessary when it is a high-performance environment It is not the holy grail! Keep the Big O in mind: for (var x = 0; x < 25.5Billion; x++) • Sequencing & parallel • Can become quite messy and unreadable
  • 29. A highly unlikely hypothetical situation • Read the files from Dir A • Merge the content of all files of Dir A into one file • Read the files from Dir B • Append the content of step 1 to all files in Dir B • Store these results in the Database
  • 30. Would look something like this aSynReadDir('A/', function(files) { mergeFiles(files, function(fileContents) { aSynReadDir('B/', function(files) { appendFiles(fileContents, files, function(appendedFiles) { insertIntoDatabase(appendedFiles, function() { }); }); }); }); });
  • 31. Useful Node Modules: Socket.io • Latest browsers support Web sockets • IE10+ • Chrome • FireFox • “Weirdly” on Android only starting from 4.4… • Socket.io leverages the Web socket technology for bi-directional communication between clients & servers: • With degradability in place for the “older” browsers!
  • 32. Socket.io continued • Very nice for real time applications with a lot of concurrent users. • Browser based games where you mobile is the controller • Second screen applications • Updating the client: • Chat • Real time statistics • News updates • Etc
  • 33. Small example (Server) var server = http.createServer(function(req, res){ //code here }); var io = socketio.listen(server); function sendRandomMessage(){ var index = Math.floor((Math.random()*4)); io.sockets.send(words[index]); }
  • 34. Small example (Client) var socket = io.connect(); socket.on('message', function (message) { console.log(„I received the message ' + message); var m = document.createElement('p'); m.innerText = message; document.getElementById('text').appendChild(m); });
  • 35. Event Listener socket.on('message', function (message)…… socket.emit(„fired‟, {message: yep, you are fired});
  • 36. Other Useful Node Modules "dependencies": { "express": "3.4.7", // Web Framework "express-validator": "1.0.1", "request": "2.25.0", // "redis": "0.10.0", //Redis: High performance in memory DB "hiredis": "0.1.16", // To make Redis even faster with C written stuff "redis-sentinel": "0.0.5", // Redis failover "http-auth": "*", //for authentication "openid": "0.5.5", //Open ID client "statsd-client": "*", //NodeJS deamon for logging request s tatistics "facebook-node-sdk": "0.2.0", "librato-metrics": "0.0.7", "statsd-client": "0.0.15" }
  • 37. ADIDAS NITROCHARGE An interactive cinematic experience using your mobile phone as a controller. 
Produced for DDB & Tribal Case Video
  • 38. KLM CLAIM YOUR PLACE IN SPACE Are you ready to win the ultimate journey of inspiration? Claim your spot in space 
Produced for DDB & Tribal Amsterdam Case Video
  • 39. THE VOICE OF HOLLAND Talpa This season you can be a coach at home. Show your coaching qualities with The Voice of Holland Thuiscoach app. Case Video
  • 40. THANK YOU! • We are looking for new awesome developers! • Questions: richard@mediamonks.com

Editor's Notes

  1. Like MediaMonks on Facebook: https://www.facebook.com/mediamonksMore information about MediaMonks: http://www.mediamonks.com/
  2. Share your participation!Facebook share moment: “I am participating in the 2nd screen presentation of @MediaMonks @FITC”Twitter share moment: “I am participating in the 2nd screen presentation of @MediaMonks @FITC”
  3. Text: “This is Ryan Dahl”{Image of Ryan Dahl}
  4. Text: “Yep, literally copy pasted it”
  5. Text: “Nothing to say here”
  6. Text:“V8 powers the Google Chrome browser”“More information on V8: https://code.google.com/p/v8/”
  7. Text: “Download Node.js here: http://nodejs.org/”Text: “Currently around 60.000 3rd Party modules! See: https://www.npmjs.org/”
  8. Question: “What JavaScript engine is Node.js using?”v2 rocketV8V7 v18Correct answer = b
  9. Text:A closer look on your phone:“{ protocol: &apos;http:&apos;, slashes: true, auth: null, host: &apos;www.mediamonks.com&apos;, port: null, hostname: &apos;www.mediamonks.com&apos;, hash: null, search: &apos;?who=richard&amp;location=fitc&apos;, query: &apos;who=richard&amp;location=fitc&apos;, pathname: &apos;/&apos;, path: &apos;/?who=richard&amp;location=fitc&apos;,href: &apos;http://www.mediamonks.com/?who=richard&amp;location=fitc&apos; }“Note for myself:Do a repl demonstration of the following code: “require(‘url’).parse(‘http://www.mediamonks.com/?who=richard&amp;location=fitc’)”
  10. Image (ugly_code.jpg)
  11. Text: “Nothing to say here”
  12. Text: “Share moment”Facebook share: “Looking at some Node.js Code @FITC”Twitter share: “Looking at some Node.js Code @FITC”
  13. Text:“Nothing to say here”
  14. Text: “Bored? Answer the following question:”Script Language = JavaScriptWhat is the value of Y at the end of the following code snippet:var x = 7;var y = ‘’;if (x++ == 8) y = &apos;The Terminator&apos;;else y = &apos;Robocop&apos;;‘’The TerminatorRobocopError, syntax errorCorrect answer = c
  15. Text: “That was freaking awesome!”Richard notes: Show them the amazing website
  16. Image: arnold.jpg
  17. Question: What do you think is the underlying technology of this application on your mobile?PollingStored in JavaScriptSockets (and fallbacks)Correct answer: CRichard notes: show them what happens when the dir name is changed
  18. Question: “Which Node.js module did I use for reading the files?”httpnetfsnsCorrect answer = c
  19. Answer the following question:What sentencewill be printed?function justWaitAMinute(cb){setTimeout(function(){cb(); }, 60000);}var text = ‘Future’;justWaitAMinute(function(){ console.log(‘What?: ‘ + text );});var text = ‘Creativity’;What?: CreativityWoot?: CreativityWhat?: FutureCorrect answer = A
  20. Text: “Nothing to say here”Node has cluster setup
  21. Text: “You might think, DUH! ”
  22. @Richard: show them it blocks by using the slowserver.jsQuestion:Which of the following is not an HTTP methodPOSTGETHEADUPDATEDELETECorrect answer: D
  23. Text: “The important thing here is that the main process is waiting for the database to return its result, while basically doing nothing resource wise. It prevents other request of being accepted”
  24. Text: “The important thing here is that the main Node process lets the Event Loop wait for all the IO call backs. This means that the main process can continue handling request for example”
  25. Text: For if you wanted to see the rest of ht code:if (err){ console.log(&apos;Crap, dir does not exist :-(&apos;); }if (typeof data != &apos;undefined&apos;){varsortedFileNames = sorter.sortFileNames(data); }html += &apos;&lt;ol&gt;&apos;;for(var index in sortedFileNames){ html += &apos;&lt;li&gt;&apos; + sortedFileNames[index] + &apos;&lt;/li&gt;&apos;; }html += &apos;&lt;/ol&gt;&apos;;sendFileNames(res, html); });
  26. Text: “See node.js documentation here: http://nodejs.org/api/. Make sure to use the A-Synchronous variants of the functions”
  27. Question: What is the Big O of the following pseudo code snippet?data = [1 , 2, …, ………];data2 = [1, 2, …, …..];for(var x = 0; x &lt; data.length; x++){ for (var y = 0; y &lt; data2.length; y++){ //do something }}n2n3nn^3n^2Answer is e
  28. Text: “Nesting happens a lot!”
  29. People’s Choice of the Year: Adidas Nitro charge uses Socket.ioDesktop: http://www.nitrochargeyourgame.com/Image: nitro.jpg
  30. Share moment:FB &amp; Twitter share “Socket.io for the win @FITC”
  31. Text: “Nothing to say here”
  32. Text: For more information on Socket.io: http://socket.io/
  33. Text ‘Nothing to say here’
  34. Text: “This is a package.json file in which you can specify module dependancies”