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

nowjs #TechLunch

nowjs #TechLunch

2011/08/31(水) @ Livesense TechLunch
発表者:桂 大介

E60aa4f80303f3f386898546ddb3686a?s=128

Livesense Inc.
PRO

April 23, 2014
Tweet

Transcript

  1. katsura@livesense.co.jp

  2. DEMO

  3. http://rcnow.herokuapp.com/

  4. None
  5. before that

  6. None
  7. Ryan Dahl

  8. node Evented Server-side Javascript

  9. Why node?

  10. C10K Problem http://code.google.com/p/node-js-vs-apache-php-benchmark/wiki/Tests

  11. C10K Problem http://en.wikipedia.org/wiki/C10k_problem The C10k problem is a limitation that

    most web servers currently have, which limits the web server to being able to handle a maximum of about ten thousand simultaneous connections.
  12. Servers which address the problem • Nginx • Lighttpd •

    Tornado@python • EventMachine@ruby • And..
  13. node.js Evented Server-side Javascript Good at handling lots of different

    kinds of I/O at the same time. Achieves this by all making network I/O nonblocking and all file I/O asynchronous. (Almost all.)
  14. node.js Node's goal is to provide an easy way to

    build scalable network programs.
  15. hello world 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");
  16. None
  17. npm npm is a package manager for node. You can

    use it to install and publish your node programs. It manages dependencies and does other cool stuff.
  18. None
  19. express High performance, high class web development for Node.js

  20. express • Robust routing • Redirection helpers • Dynamic view

    helpers • Application level view options • Content negotiation • Application mounting • Focus on high performance • View rendering and partials support • Environment based configuration • Session based flash notifications • Built on Connect • Executable for generating applications quickly • High test coverage
  21. hello world var express = require('express'); var app = express.createServer();

    app.get('/', function(req, res){ res.send('Hello World'); }); app.listen(3000);
  22. hello world in Sinatra require 'sinatra' get '/' do "Hello

    World!" end
  23. None
  24. npm install now

  25. on heroku

  26. package.json (like Bundler) { "name": "node-example", "version": "0.0.1", "dependencies": {

    "now": "0.7.2" } }
  27. Client-side source $(document).ready(function(){ now.receiveMessage = function(name, message){ $("#messages").append("<br>" + name

    + ": " + message); } $("#send-button").click(function(){ now.distributeMessage($("#text-input").val()); $("#text-input").val(""); }); now.name = prompt("What's your name?", ""); });
  28. Server-side source var html = require('fs').readFileSync(__dirname+'/helloworld.html'); var server = require('http').createServer(function(req,

    res){ res.end(html); }); server.listen(process.env.PORT); var nowjs = require("now"); var everyone = nowjs.initialize(server); everyone.now.distributeMessage = function(message){ everyone.now.receiveMessage(this.now.name, message); };
  29. Programming Language

  30. 200X

  31. 200X

  32. 201X

  33. None
  34. 予告

  35. null, nil, None, Nothing 0, Nullable, Mu ?

  36. null に関する一考察