Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SkillSwap node.js

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →
Seth Vargo
September 08, 2012

SkillSwap node.js

These are the slides from my tech talk given at skill swap at CMU for SkillSwap Weekend.

Seth Vargo

September 08, 2012

Transcript

70 slides
  1. 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/');
  2. 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/'); 1 2 3 4 5 6 7 8 ... in just 8 lines
  3. npm

  4. var data = file.read('scotty-labs.txt'); // Tie up the CPU while

    I read that file complexFileOperation(data); Old I/O
  5. var data = file.read('scotty-labs.txt', function(data) { complexFileOperation(data); }); // let

    the CPU keep working in the meantime otherFunction(); New I/O
  6. var data = file.read('scotty-labs.txt', function(data) { complexFileOperation(data); }); // let

    the CPU keep working in the meantime while(true) { ... } what does this do?
  7. var data = file.read('scotty-labs.txt', function(data) { complexFileOperation(data); }); // let

    the CPU keep working in the meantime while(true) { ... } what does this do?
  8. var data = file.read('scotty-labs.txt', function(data) { // never fires });

    // blocks the entire thread while(true) { ... } what does this do?
  9. var data = file.read('scotty-labs.txt', function(data) { // never fires });

    // blocks the entire thread while(true) { ... } nothing...

More Decks by Seth Vargo

Other Decks in Technology