![Page 1: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/1.jpg)
Node.jsHow JavaScript is Changing Server Programming
Tom Hughes-Croucher @sh1mmer
![Page 2: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/2.jpg)
This is how we roll
1. Server-Side JavaScript Overview
2. Introduction to Node.js
3. The Node.js ecosystem
4. Getting started
![Page 3: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/3.jpg)
Server Side Javascript IS SO AWESOMEMY ENTIRE PRESENTATION IS IN
COMIC SANS AND YOU WILL STILL LOVE ME AT THE END
![Page 4: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/4.jpg)
Why SSJS?
![Page 5: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/5.jpg)
JavaScript programmers
3 > 2 > 1
![Page 6: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/6.jpg)
Massive Code base of YUI and other JS librariesI heard some people use this thing called jQuery,
but I’m not convinced it’ll catch on
![Page 7: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/7.jpg)
Laziness or “I’m sick of writing stuff twice”I could have said efficiency, but I think we all secretly long
to lounge around in our y-fronts.
![Page 8: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/8.jpg)
Progressive Enhancement is free*Remember WWCD (What Would Crockford Do)
*close enough
![Page 9: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/9.jpg)
TL;DR:SSJS is Awesome
Like a Unicorn riding a Narwhal
![Page 10: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/10.jpg)
![Page 11: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/11.jpg)
Why now?
![Page 12: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/12.jpg)
1. Professionalism
![Page 13: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/13.jpg)
![Page 14: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/14.jpg)
“Yahoo!'s corporate motto is: Don't be
eval().“
![Page 15: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/15.jpg)
“Doug Crockford's JavaScript is so strict, that uncaught
exceptions would trigger global thermonuclear war“
![Page 16: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/16.jpg)
2. JavaScript Runtimes
![Page 17: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/17.jpg)
Runtimes
• V8 (Google), C++
• Spider Monkey (Mozilla), C++
• Rhino (Mozilla), Java
• JavaScript Core (Apple), C++
![Page 18: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/18.jpg)
JavaScript Performance
V8
Spider Monkey
![Page 19: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/19.jpg)
Node.js• Server-side JavaScript process
• Uses V8
• Non-blocking
• Event Driven
• CommonJS module format
![Page 20: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/20.jpg)
Node.js• Server-side JavaScript process
• Uses V8
• Non-blocking
• Event Driven
• CommonJS module format
AWESOME!
![Page 21: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/21.jpg)
Node is ☜⎻⎻⎻⎻⎻☞
this fast
![Page 22: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/22.jpg)
concurrency=300, Smaller is Better
response size (bytes)
resp
on
se
tim
e (
ms)
100
200
300
400
24
26
28
210
212
214
216
218
server
nginxthintornadonode_buffer
![Page 23: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/23.jpg)
![Page 24: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/24.jpg)
Why non-blocking matters
![Page 25: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/25.jpg)
var result = db.query("select * from T"); // use result
![Page 26: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/26.jpg)
What are we waiting for?
![Page 27: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/27.jpg)
Event Loop vs. Threads
![Page 28: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/28.jpg)
Apache vs NGINXconcurrency ! reqs/sec
http://blog.webfaction.com/a-little-holiday-present
![Page 29: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/29.jpg)
Apache vs NGINXconcurrency ! memory
http://blog.webfaction.com/a-little-holiday-present
![Page 30: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/30.jpg)
Node Basics
![Page 31: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/31.jpg)
var http = require('http');http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n');}).listen(8124, "127.0.0.1");console.log('Server running at http://127.0.0.1:8124/');
![Page 32: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/32.jpg)
var http = require('http');
//include the http library
![Page 33: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/33.jpg)
http.createServer(function (req, res) {
}).listen(8124, "127.0.0.1");
//create an http server//when ‘stuff’ happens call this anonymous function//listen on port 8124 of the IP 127.0.0.1
![Page 34: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/34.jpg)
http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n');})
//when ‘stuff’ happens my function fires//I get a request object and a response object//I write to the response object header//HTTP status 200 and content-type ‘text/plain’//close the response with the body://Hello World
![Page 35: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/35.jpg)
console.log('Server running at http://127.0.0.1:8124/');
//write Server is running at http://127.0.0.1:8124///to the console
![Page 36: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/36.jpg)
Node Ecosystem
![Page 37: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/37.jpg)
![Page 38: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/38.jpg)
![Page 39: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/39.jpg)
![Page 40: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/40.jpg)
![Page 41: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/41.jpg)
![Page 42: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/42.jpg)
![Page 43: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/43.jpg)
![Page 44: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/44.jpg)
![Page 45: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/45.jpg)
![Page 46: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/46.jpg)
![Page 47: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/47.jpg)
NPMNode Package Manager
![Page 48: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/48.jpg)
npm install mustache
![Page 49: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/49.jpg)
NPM is written in JavaScript!
![Page 50: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/50.jpg)
// kludge until this is normal.if (!process.EventEmitter.prototype.on) { process.EventEmitter.prototype.on = process.EventEmitter.prototype.addListener}var path = require("path")if (!process.execPath) { process.execPath = path.join(process.installPrefix, "bin", "node")}
var npm = exports , set = require("./lib/utils/set") , get = require("./lib/utils/get") , ini = require("./lib/utils/ini") , log = require("./lib/utils/log") , fs = require("fs")
npm.commands = {}npm.SHOULD_EXIT = true
try { var j = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))+"") npm.version = j.version} catch (ex) { log(ex, "error reading version") npm.version = ex}
![Page 51: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/51.jpg)
node-replInteractive JavaScript terminal
![Page 52: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/52.jpg)
Which libraries to use?
![Page 53: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/53.jpg)
Mustache.js
![Page 54: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/54.jpg)
![Page 55: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/55.jpg)
var view = { title: "Joe", calc: function() { return 2 + 4; }}
var template = "{{title}} spends {{calc}}";
var html = Mustache.to_html(template, view);
![Page 56: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/56.jpg)
node-paperboy
![Page 57: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/57.jpg)
![Page 58: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/58.jpg)
http://wargamez.mape.me/
![Page 59: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/59.jpg)
![Page 60: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/60.jpg)
DOM+YUI3
![Page 61: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/61.jpg)
Rendering HTML
http://yuiloader.davglass.com/calendar/
![Page 62: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/62.jpg)
Multi-core Node.jsNode+Web Workers
![Page 63: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/63.jpg)
var sys = require('sys');var Worker = require('webworker').Worker;
var w = new Worker('foo.js');
w.onmessage = function(e) { sys.debug('Received mesage: ' + sys.inspect(e)); w.terminate();};
w.postMessage({ foo : 'bar' });
onmessage = function(e) { postMessage({ test : 'this is a test' });};
onclose = function() { sys.debug('Worker shuttting down.');};
Master
Worker
![Page 64: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/64.jpg)
Summary• SSJS is awesome because
• We are JavaScript programmers
• Reuse (libraries/code)
• Progressive Enhancement
• Node.js + YUI3 rocks
• YUI 3’s was easy to get running on Node.js
• Server side DOM allows for a single code base
![Page 65: Node - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Node_js and How JavaScript is... · nginx thin tornado node_buffer. Why non-blocking matters. var result = db.query("select *](https://reader034.vdocuments.us/reader034/viewer/2022052419/5a72e69b7f8b9a93538e4357/html5/thumbnails/65.jpg)
Today presentation wasBrought to you by
the letters:J and S
And the fonts:Comic Sansmonofur
Tom Hughes-Croucher@sh1mmer
Slides, etc --> http://speakerrate.com/sh1mmer
Pls rate me. kthxbai.