brought to you by coloradosprings js presented by brian
play

Brought to you by coloradosprings.js Presented by Brian Parks Who - PowerPoint PPT Presentation

Brought to you by coloradosprings.js Presented by Brian Parks Who am I? Brian Parks Founder and CEO of Synapse Software (synapsesoftware.com) From C to PHP and .NET Javascript is awesome! http://slidesha.re/1jCKMMD What


  1. Brought to you by coloradosprings.js 
 Presented by Brian Parks

  2. Who am I? • Brian Parks • Founder and CEO of Synapse Software (synapsesoftware.com) • From C to PHP and .NET • Javascript is awesome! • http://slidesha.re/1jCKMMD

  3. What is node.js? • “Evented [non-blocking] I/O for V8 Javascript” • 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. • https://www.youtube.com/watch?v=jo_B4LTHi3I

  4. Why use node.js • High throughput • Real-time collaboration • Horizontal scalability • Evented model • Javascript for web, network, console • Node Package Manager

  5. Where do I get it? • Homebrew package manager (Mac OS X) • Github (All platforms) • http://nodejs.org/download/

  6. Non-blocking • PHP echo “hello”; 
 sleep(2); 
 echo “world”; • node.js setTimeout(function() { console.log(“world”); }, 2000); console.log(“hello”);

  7. A quick example var net = require('net'); � var server = net.createServer(function (socket) { socket.write('Echo server\r\n'); socket.pipe(socket); }); � server.listen(1337, '127.0.0.1');

  8. In the real world • Verimail - small service that responds whether the server running it is authorized to send mail for a given email address • https://github.com/bparks/verimail

  9. A more realistic example 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/'); • Run with telnet localhost 1337 > GET / > • Notice the “Content-Encoding: chunked” response header

  10. Using chunking var http = require('http'); � http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain; charset=UTF-8'}); res.write('Hello\r\n'); setTimeout(function () { res.end('World\r\n'); }, 2000); }).listen(1337, '127.0.0.1'); � console.log('Server running at http://127.0.0.1:1337/'); • Run with telnet localhost 1337 > GET / >

  11. In the real world • Etherpad - Really real-time collaborative document editing for the rest of us (http:// etherpad.org) • https://github.com/ether/etherpad-lite

  12. Goggles • http://goggles.sneakygcr.net • A full-fledged node.js app written when node.js was very new. • Most of Goggles is open source at https:// github.com/gcr/goggles • Highly-collaborative, real-time

  13. Other node.js stuff • express.js • npm (node package manager) • Code in this presentation will also be uploaded to github: https://github.com/bparks/node-demo • To get the code: git clone https://github.com/bparks/ node-demo.git git submodule init git submodule update

Recommend


More recommend