Slide 1

Slide 1 text

why? @rafaelverger

Slide 2

Slide 2 text

anyone? What problem Node.js tries to solve?

Slide 3

Slide 3 text

I/O L . . .

Slide 4

Slide 4 text

loading next slide ... I/O L . . .

Slide 5

Slide 5 text

I/O Latency

Slide 6

Slide 6 text

Web servers basic workflow

Slide 7

Slide 7 text

How to solve it? THREEEEEEEEEEEEEEEEEADS :) THREEEEEEEEEEEEEEEEEADS :) THREEEEEEEEEEEEEEEEEADS :) THREEEEEEEEEEEEEEEEEADS :)

Slide 8

Slide 8 text

How to solve it? THREADS...

Slide 9

Slide 9 text

Threads or Subprocesses That's how we used to scale our apps 1. 2. idle busy

Slide 10

Slide 10 text

How Node.js works Single process, Event Loop, Async I/O idle busy

Slide 11

Slide 11 text

Node.js Event Loop

Slide 12

Slide 12 text

How Node.js is built? libuv

Slide 13

Slide 13 text

How Node.js code looks like? var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/');

Slide 14

Slide 14 text

Bad stuff / Callback Hell :( @helielson

Slide 15

Slide 15 text

Bad stuff / Callback Hell :(

Slide 16

Slide 16 text

SOLVED \o/ Bad stuff / Callback Hell :(

Slide 17

Slide 17 text

Since Node.js use only 1 single thread/process, in a single core, if a tasks takes too long to complete, the whole app will be stuck... Bad stuff / CPU Intensive tasks :( But don't worry.. it's very easy to spawn a child process and let him do the job :)

Slide 18

Slide 18 text

Bad stuff / CPU Intensive tasks :( SOLVED spawning a child process \o/

Slide 19

Slide 19 text

Bad stuff / Not a large community

Slide 20

Slide 20 text

Bad stuff / Not a large community

Slide 21

Slide 21 text

Bad stuff / Not a large community Now, in English:

Slide 22

Slide 22 text

Goooood stuff :) - HUUUUGE Community! - Native and MANDATORY event driven programming - ES5 is all there - ES6 is almost done - Cross-platform (desktop, web, mobile, linux, windows, osx, one language to rule them all!! )

Slide 23

Slide 23 text

Node.js Community

Slide 24

Slide 24 text

Who builds Node.js ? We :D https://github.com/joyent/node Core committers (companies): Joyent, Strongloop, Chrome, Mozilla and Microsoft

Slide 25

Slide 25 text

Who uses Node.js eBay LinkedIn Trello Yahoo Microsoft ...

Slide 26

Slide 26 text

Node.js beyond web Tessel.io Nodebots Johnny Five Nodecopter

Slide 27

Slide 27 text

Final review Event driven programming Async I/O Huge community One language to rule them all The best part of JavaScript Open source: https://github.com/joyent/node

Slide 28

Slide 28 text

Questions? I know that you guys left shame at home

Slide 29

Slide 29 text

Thanks! You're awesome! @rafaelveger

Slide 30

Slide 30 text

References https://www.youtube.com/watch?v=L0pjVcIsU6A https://www.promisejs.org/ http://callbackhell.com/ http://nodejs.org/api/child_process.html#child_process_child_pid http://strongloop.com/strongblog/promises-in-node-js-with-q-an-alternative-to-callbacks/ http://misclassblog.com/interactive-web-development/node-js/