• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Node.js
 

Node.js

on

  • 2,571 views

 

Statistics

Views

Total Views
2,571
Views on SlideShare
2,570
Embed Views
1

Actions

Likes
1
Downloads
27
Comments
0

1 Embed 1

http://paper.li 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Node.js Node.js Presentation Transcript

  • mat@schaffer.me@matschafferhttp://github.com/matschafferhttp://mashion.netdidn’t write node.js
  • I’m not Ryan Dahlbut he’ll be atPhilly ETE
  • What is ?
  • ?
  • But why?
  • • Larger developer pool• Write-once business logic• Server-side fallbacks but also....
  • Asynchonous vs.Synchronous
  • // Asynchronous$.get(ajax/test.html,      function(data) {        $(.result).html(data);        alert(Async!);      });
  • // Synchronousvar data = $.get(ajax/test.html);
  • Evented (async) vs.Threaded (sync)
  • Getting it (source)git clone git://github.com/ry/node.gitcd node./configure --prefix=/usr/localmakemake install || sudo make install
  • Getting it (packaged) brew install node port install nodejs
  • Node Basics
  • console.log(hello world);$ node helloworld.jshello world
  • var fs = require(fs);fs.writeFile(hello.txt, hello world, function (err, fd) {   if (err) throw err;   console.log(done.); });$ node helloworld.jsdone.$ cat hello.txthello world
  • var fs = require(fs);• require(‘mylib’) ≈ <script src=”mylib.js”>• require returns the library’s exports
  • module.exports = {  writeFile: function(path, data, callback) {...},  readFile: function(path, callback) {...}};
  • A web server
  • var http = require(http);http.createServer(function (req, res) {  res.writeHead(200,    {Content-Type: text/plain});  res.end("Hello worldn");}).listen(8000);
  • Working with Evented Libraries
  • not this...things.each(function(thing) {  doStuffWith(i);});
  • this!things.each(function(thing, next) {  doStuffWith(i, next);});
  • Get packages with npm npm install express
  • Testing Options• Built in assert library• Jasmine• Expresso• Vows
  • Cool Node.js Projects
  • node-inspector
  • Expressvar express = require(express),    app = express.createServer();app.get(/, function(req, res){    res.send(Hello World);});app.listen(3000);
  • Socket.IO Real time client/server messaging// socket.iovar socket = io.listen(server);socket.on(connection, function(client){  // new client is here!  client.on(message, function(){ … })  client.on(disconnect, function(){ … })});
  • Massively multiplayer scrabble!!1!1!!
  • App in a browser!!
  • Analytics pr0n!11!!!!1