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

brought to you by coloradosprings js presented by brian
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Brought to you by coloradosprings.js
 Presented by Brian Parks

slide-2
SLIDE 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
slide-3
SLIDE 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
slide-4
SLIDE 4

Why use node.js

  • High throughput
  • Real-time collaboration
  • Horizontal scalability
  • Evented model
  • Javascript for web, network, console
  • Node Package Manager
slide-5
SLIDE 5

Where do I get it?

  • Homebrew package manager (Mac OS X)
  • Github (All platforms)
  • http://nodejs.org/download/
slide-6
SLIDE 6

Non-blocking

  • PHP

echo “hello”;
 sleep(2);
 echo “world”;

  • node.js

setTimeout(function() { console.log(“world”); }, 2000); console.log(“hello”);

slide-7
SLIDE 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');
slide-8
SLIDE 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
slide-9
SLIDE 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
slide-10
SLIDE 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 / >

slide-11
SLIDE 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
slide-12
SLIDE 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
slide-13
SLIDE 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