O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.
About Node
Rick Chang
What is Node
A Platform to write JavasScript applications
outside web browsers.
No DOM
No bowser capability
Act as a web s...
About Node
No thread (run single-threaded)
Event-driven architecture (publish/subscribe)
Google V8 JavaScript engine
Non-b...
History
Ryan Dahl created in 2009[1]
chose JavaScript because of the lack of an existing I/O API
Build high performance an...
Server-side JavaScript
RingoJS (http://ringojs.org/)
Based on Mozilla Rhino and written in
Java
Node
Based on Google V8
JavasScript
loosely typed
dynamically extendable objects
anonymous closures
Pub/Sub Pattern
pub.sub.js Result
foo 1 2
foo.bar 1 2
foo.baz 1 2
!
foo.bar 3 4
!
foo.baz 5 6
!
foo 7 8
foo.baz 7 8
Extend Object
Dynamically
people.js
The employee works
hard
Drive vehicle
Result
JavaScript vs Java
Java
Non-dynamic language
Static typed
The compiler catch programming mistakes
JavaScript
Dynamic langu...
Node.js
CommonJS module system
Make variables local to a module
Demo code
Demo
parent.js example.js
Asynchronous I/O
A single-thread event loop without thread context switch
Callback function to handle result
result = quer...
Benchmark
var http = require('http');	

http.createServer(function (req, res) {	

res.writeHead(200, {'Content-Type': 'tex...
Company
Yahoo!
LinkedIn
Replace Ruby on Rails to Node
Paypal
Conclusion
Node is a great platform for I/O-bound
applications
No good for computationally expensive
calculations
Finbonac...
Debate
Node.js favours performance over usability and robustness
Difficult to debug, refactor and develop
no synchronous co...
Reference
[1]Node.js, http://en.wikipedia.org/wiki/Node.js
[2]Joyent, https://www.joyent.com/
[3]Farewell Node.js, TJ Holo...
Próximos SlideShares
Carregando em…5
×

de

Node Web Development 2nd Edition: Chapter1 About Node Slide 1 Node Web Development 2nd Edition: Chapter1 About Node Slide 2 Node Web Development 2nd Edition: Chapter1 About Node Slide 3 Node Web Development 2nd Edition: Chapter1 About Node Slide 4 Node Web Development 2nd Edition: Chapter1 About Node Slide 5 Node Web Development 2nd Edition: Chapter1 About Node Slide 6 Node Web Development 2nd Edition: Chapter1 About Node Slide 7 Node Web Development 2nd Edition: Chapter1 About Node Slide 8 Node Web Development 2nd Edition: Chapter1 About Node Slide 9 Node Web Development 2nd Edition: Chapter1 About Node Slide 10 Node Web Development 2nd Edition: Chapter1 About Node Slide 11 Node Web Development 2nd Edition: Chapter1 About Node Slide 12 Node Web Development 2nd Edition: Chapter1 About Node Slide 13 Node Web Development 2nd Edition: Chapter1 About Node Slide 14 Node Web Development 2nd Edition: Chapter1 About Node Slide 15 Node Web Development 2nd Edition: Chapter1 About Node Slide 16 Node Web Development 2nd Edition: Chapter1 About Node Slide 17
Próximos SlideShares
Ch2.setup.node.and.npm
Avançar
Transfira para ler offline e ver em ecrã inteiro.

0 gostaram

Compartilhar

Baixar para ler offline

Node Web Development 2nd Edition: Chapter1 About Node

Baixar para ler offline

Node Web Development 2nd Edition: Chapter1 About Node

  • Seja a primeira pessoa a gostar disto

Node Web Development 2nd Edition: Chapter1 About Node

  1. 1. About Node Rick Chang
  2. 2. What is Node A Platform to write JavasScript applications outside web browsers. No DOM No bowser capability Act as a web server Care about HTTP headers
  3. 3. About Node No thread (run single-threaded) Event-driven architecture (publish/subscribe) Google V8 JavaScript engine Non-block I/O event loop (Asynchronous I/O) File and network I/O libraries (use multiple threads)
  4. 4. History Ryan Dahl created in 2009[1] chose JavaScript because of the lack of an existing I/O API Build high performance and scalable network applications Sponsored by Joyent[2] Inspired By seeing a file upload progress bar on Flickr npm created by Isaac Schlueter, a package manager was introduced in 2011 Microsoft partnered to create a native Windows version in July 2011
  5. 5. Server-side JavaScript RingoJS (http://ringojs.org/) Based on Mozilla Rhino and written in Java Node Based on Google V8
  6. 6. JavasScript loosely typed dynamically extendable objects anonymous closures
  7. 7. Pub/Sub Pattern pub.sub.js Result foo 1 2 foo.bar 1 2 foo.baz 1 2 ! foo.bar 3 4 ! foo.baz 5 6 ! foo 7 8 foo.baz 7 8
  8. 8. Extend Object Dynamically people.js The employee works hard Drive vehicle Result
  9. 9. JavaScript vs Java Java Non-dynamic language Static typed The compiler catch programming mistakes JavaScript Dynamic language Loosely typed Global Object Global Object cause an unruly chaos!!
  10. 10. Node.js CommonJS module system Make variables local to a module Demo code
  11. 11. Demo parent.js example.js
  12. 12. Asynchronous I/O A single-thread event loop without thread context switch Callback function to handle result result = query('SELECT * from db'); // operate on the result query('SELECT * from db', function (err, result) { if (err) throw err; // handle errors // operate on result });
  13. 13. Benchmark var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(8124, "127.0.0.1"); console.log('Server running at http://127.0.0.1:8124/'); Node Nginx Throughput 822 req/sec 704 req/sec Memory Used 64M 4M
  14. 14. Company Yahoo! LinkedIn Replace Ruby on Rails to Node Paypal
  15. 15. Conclusion Node is a great platform for I/O-bound applications No good for computationally expensive calculations Finbonacci sequence calcuation More performance, fewer servers, lower cost and lower environment impact
  16. 16. Debate Node.js favours performance over usability and robustness Difficult to debug, refactor and develop no synchronous code duplicate callback emitters may get multiple “error” events missing “error” events sends everything to hell “error” handlers are very verbose
  17. 17. Reference [1]Node.js, http://en.wikipedia.org/wiki/Node.js [2]Joyent, https://www.joyent.com/ [3]Farewell Node.js, TJ Holowaychuk, https://medium.com/code- adventures/farewell-node-js-4ba9e7f3e52b [4]关于TJ⼤大神的Farewell Node.js, http://www.welefen.com/about-tj- farewell-node.js-article.html [5]JavaScript模块化开发(⼆二)—CommonJS规范, http:// www.feeldesignstudio.com/2013/09/javascript-module-pattern-commonjs [6]CommonJS规范, http://javascript.ruanyifeng.com/nodejs/ commonjs.html

Node Web Development 2nd Edition: Chapter1 About Node

Vistos

Vistos totais

496

No Slideshare

0

De incorporações

0

Número de incorporações

22

Ações

Baixados

8

Compartilhados

0

Comentários

0

Curtir

0

×