NodeJS和NodeJS在中国
 @朴灵
 #Front-end Engineer#
 #Mobile Web App# #V5#
 #NodeJS#
 #EventProxy#
   What’s NodeJS
   Why NodeJS
   How to use NodeJS
   Who uses NodeJS
   CNodeJS(NodeJS in China)
Ryan Dahl
Evented I/O for V8 JavaScript

Goal:
Provide an easy way to build
scalable network programs
 May 2009, initial release
 November 2011, v0.6
 v0.8 in Roadmap
 5000+ modules/libraries in NPM
Why?
       Ruby



???           Python




Java          ASP.NET



       PHP
 Events
 Non-Blocking I/O
 JavaScript & V8
     浏览器战争
   Single thread
Ads
            勋章




Timeline




           Topics
m+n   max(m, n)
m+n+x     max(m + n
 +y + …   + x + y + …)
   ……
   $timeline = get_timeline();
   $ads = get_ads();
   $badages = get_badages();
   ……
 get_timeline(function (timeline){
      // TODO
  });
 get_ads(function (ads){
      // TODO
  });
 get_badages(function (badages){
      // TODO
  });
   HTTP/HTTPS
   TCP/UDP
   DNS
   File System
   Stream
   Child Process
   …
   JavaScript at Frontend and Backend both
     代码复用
     经验共享
   JavaScript Anywhere
     CLI
     Web Server
     TCP Server
     GUI(Webkit)
Any application that can
be written in JavaScript,
will eventually be written
in JavaScript
   Prerequisites
     make
     wget
     gcc/g++
     Python(2.6 <= version <3.0)
     Libssl-dev
   wget http://nodejs.org/dist/v0.6.1/node-v0.6.1.tar.gz
   tar zxvf node-v0.6.1.tar.gz
   cd node-v0.6.1
   ./configure
   make
   make install
 curl http://npmjs.org/install.sh | sh
 npm install express
var http = require('http');
http.createServer(function (req, res) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello Worldn');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');


% node example.js
Server running at http://127.0.0.1:1337/
   LinkedIn -> Mobile
   Yammer -> Cross Domain
   Github -> Download
   Yahoo! -> Mojito & Cocktails
   Voxer -> Realtime Voice
   VMWare
   …
   Taobao -> myfox
   Aliyun
   Sina -> SAE
   Sohu
   雪球财经
   …
Next?   北京




香港                上海




     广州      杭州
12月25日 13:30(周日)
上海浦东新区张江高科技园区碧波路690号3号楼
免费
报名:http://event.weibo.com/275553
   书法 http://sufa.cnodejs.net/
   在线协作绘画 http://paintchat.cnodejs.net/
   关键字日记 http://keydiary.cnodejs.net
   NodeBook http://nodebook.jit.im
   CNUG
    http://groups.google.com/group/cnodejs
     952 posts
     332 members
   CNodeJS
    http://cnodejs.org
     131 posts
 API: http://cnodejs.org/cman/
 InfoQ: 深入浅出Nodejs专栏
     http://www.infoq.com/cn/articles/nodejs-in-front-end-
      engineer-view
     http://www.infoq.com/cn/news/2011/11/tyq-nodejs-
      static-file-server
 The Node Beginner Book
  http://nodebeginner.org/index.html
  http://nodebeginner.org/index-zh-cn.html
 Up and Running with Node.js
  http://ofps.oreilly.com/titles/9781449398583/index.ht
  ml
 What’s Node
  http://radar.oreilly.com/2011/07/what-is-node.html
  http://ued.taobao.com/blog/2011/09/02/what-is-nod/
Q&A
   http://nodejs.org/
   https://github.com/joyent/node
   http://cnodejs.net/
   http://cnodejs.org
   http://npmjs.org

(C)NodeJS

  • 1.
  • 3.
     @朴灵  #Front-endEngineer#  #Mobile Web App# #V5#  #NodeJS#  #EventProxy#
  • 4.
    What’s NodeJS  Why NodeJS  How to use NodeJS  Who uses NodeJS  CNodeJS(NodeJS in China)
  • 5.
  • 6.
    Evented I/O forV8 JavaScript Goal: Provide an easy way to build scalable network programs
  • 7.
     May 2009,initial release  November 2011, v0.6  v0.8 in Roadmap  5000+ modules/libraries in NPM
  • 10.
    Why? Ruby ??? Python Java ASP.NET PHP
  • 12.
     Events  Non-BlockingI/O  JavaScript & V8  浏览器战争  Single thread
  • 13.
    Ads 勋章 Timeline Topics
  • 16.
    m+n max(m, n)
  • 17.
    m+n+x max(m + n +y + … + x + y + …)
  • 18.
    ……  $timeline = get_timeline();  $ads = get_ads();  $badages = get_badages();  ……
  • 19.
     get_timeline(function (timeline){ // TODO });  get_ads(function (ads){ // TODO });  get_badages(function (badages){ // TODO });
  • 20.
    HTTP/HTTPS  TCP/UDP  DNS  File System  Stream  Child Process  …
  • 21.
    JavaScript at Frontend and Backend both  代码复用  经验共享  JavaScript Anywhere  CLI  Web Server  TCP Server  GUI(Webkit)
  • 22.
    Any application thatcan be written in JavaScript, will eventually be written in JavaScript
  • 25.
    Prerequisites  make  wget  gcc/g++  Python(2.6 <= version <3.0)  Libssl-dev
  • 26.
    wget http://nodejs.org/dist/v0.6.1/node-v0.6.1.tar.gz  tar zxvf node-v0.6.1.tar.gz  cd node-v0.6.1  ./configure  make  make install
  • 27.
     curl http://npmjs.org/install.sh| sh  npm install express
  • 28.
    var http =require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(1337, "127.0.0.1"); console.log('Server running at http://127.0.0.1:1337/'); % node example.js Server running at http://127.0.0.1:1337/
  • 29.
    LinkedIn -> Mobile  Yammer -> Cross Domain  Github -> Download  Yahoo! -> Mojito & Cocktails  Voxer -> Realtime Voice  VMWare  …
  • 30.
    Taobao -> myfox  Aliyun  Sina -> SAE  Sohu  雪球财经  …
  • 32.
    Next? 北京 香港 上海 广州 杭州
  • 33.
  • 34.
    书法 http://sufa.cnodejs.net/
  • 35.
    在线协作绘画 http://paintchat.cnodejs.net/
  • 36.
    关键字日记 http://keydiary.cnodejs.net
  • 37.
    NodeBook http://nodebook.jit.im
  • 39.
    CNUG http://groups.google.com/group/cnodejs  952 posts  332 members  CNodeJS http://cnodejs.org  131 posts
  • 40.
     API: http://cnodejs.org/cman/ InfoQ: 深入浅出Nodejs专栏  http://www.infoq.com/cn/articles/nodejs-in-front-end- engineer-view  http://www.infoq.com/cn/news/2011/11/tyq-nodejs- static-file-server
  • 41.
     The NodeBeginner Book http://nodebeginner.org/index.html http://nodebeginner.org/index-zh-cn.html  Up and Running with Node.js http://ofps.oreilly.com/titles/9781449398583/index.ht ml  What’s Node http://radar.oreilly.com/2011/07/what-is-node.html http://ued.taobao.com/blog/2011/09/02/what-is-nod/
  • 42.
  • 43.
    http://nodejs.org/  https://github.com/joyent/node  http://cnodejs.net/  http://cnodejs.org  http://npmjs.org