Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
A brief intro to nodejs
Jay LJLU from Evenex team
• Built on Chrome’s JavaScript runtime
• Event-driven
• Non-blocking IO
• Easily building Fast, scalable network applicati...
Built on Chrome’s JavaScript runtime
• Server side, V8 engine
• Fast
• ECMA 5 standards compliance
• “api bits that aren’t...
Event-driven
• EventEmitter
• Event loop in libev
• Functional programming in JS
– First-class functions
– Closure
• Used ...
Non-blocking IO 1/2
• “I/O is expensive”
Non-blocking IO 2/2
• Long polling (chatroom/whiteboard), socket.io
• Streaming, (Byte)Buffer
• Blocking vs non-blocking
•...
Easily building fast, scalable network
application 1/2
• Easy
– “NodeJs is the new Java”
– Fancy core library
– No compile...
Easily building fast, scalable network
application 2/2
• One language rule all. MEAN Stack.
• “web”=>“network”
• TJ Holowa...
Engineering
• NPM
• IDE
• Deployment
• Coding style
• Testing
• Debugging
• When to use nodejs
• Companies using NodeJs
Engineering
NPM
• Node packaged modules
– https://npmjs.org
– Now part of core node
– Easily manage dependencies
– package...
Engineering
IDE
• WebStorm
– Commercial license
– Truly IDE , good for beginner
• Sublime text
– Free to use
– Syntax high...
Engineering
deployment
• Single thread, single process
– Utilize my 8 cores CPU ? (new cluster module)
• Integrate with le...
Engineering
coding style
• Callback hell
– Async.js to rescue
• err as first argument
– Handle error first !
• Extending p...
Engineering
Testing
• Mocha
– Fancy reports
– BDD, TDD
– Timeout – good for asyc
– Runs in browser as well
• CI : grunt+je...
Engineering
debugging
• Chrome developer tool
– Eclipse based
• Node-inspector
– Browser based
Engineering
when to use nodejs
• When to use Node.js:
• Use Node.js to:
• Build a (soft) real-time social app like Twitter...
Companies using NodeJs
• LinkedIn, mobile webapp
• Ebay, data retrival gateway
• Github, for downloads
• Dow Jones & Compa...
Refs and links
• http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/
• http://www.slideshare.net/the_und...
Getting started !!
• git checkout https://github.com/joyent/node
• ./configure && make && sudo make install
• vi example.j...
Thanks !
• 刘立杰 Jay LJLU
More interesting…
• CoffeeScript
• Twitter Bower
• Yeoman/grunt
• phantomjs
Upcoming SlideShare
Loading in …5
×

A brief intro to nodejs

1,371 views

Published on

introduction to node.js

Published in: Technology
  • Be the first to comment

A brief intro to nodejs

  1. 1. A brief intro to nodejs Jay LJLU from Evenex team
  2. 2. • Built on Chrome’s JavaScript runtime • Event-driven • Non-blocking IO • Easily building Fast, scalable network application
  3. 3. Built on Chrome’s JavaScript runtime • Server side, V8 engine • Fast • ECMA 5 standards compliance • “api bits that aren’t considered safe to use in a web setting but are built in to node’s V8 engine.” • Choosing JS over C,Lua,Haskell,Ruby
  4. 4. Event-driven • EventEmitter • Event loop in libev • Functional programming in JS – First-class functions – Closure • Used across all core modules
  5. 5. Non-blocking IO 1/2 • “I/O is expensive”
  6. 6. Non-blocking IO 2/2 • Long polling (chatroom/whiteboard), socket.io • Streaming, (Byte)Buffer • Blocking vs non-blocking • Context switch is expensive • C10K problem • Share same architecture with nginx
  7. 7. Easily building fast, scalable network application 1/2 • Easy – “NodeJs is the new Java” – Fancy core library – No compile, fast iteration
  8. 8. Easily building fast, scalable network application 2/2 • One language rule all. MEAN Stack. • “web”=>“network” • TJ Holowaychuk
  9. 9. Engineering • NPM • IDE • Deployment • Coding style • Testing • Debugging • When to use nodejs • Companies using NodeJs
  10. 10. Engineering NPM • Node packaged modules – https://npmjs.org – Now part of core node – Easily manage dependencies – package.json
  11. 11. Engineering IDE • WebStorm – Commercial license – Truly IDE , good for beginner • Sublime text – Free to use – Syntax highlight – Code template/completion – Node plugin
  12. 12. Engineering deployment • Single thread, single process – Utilize my 8 cores CPU ? (new cluster module) • Integrate with legacy services, not replace – Consumes JSON RESTful services • Run behind Nginx – Not stable enough to be a web server • Hosting
  13. 13. Engineering coding style • Callback hell – Async.js to rescue • err as first argument – Handle error first ! • Extending prototype – Do not extend the prototypes of any objects, especially native ones
  14. 14. Engineering Testing • Mocha – Fancy reports – BDD, TDD – Timeout – good for asyc – Runs in browser as well • CI : grunt+jenkins – Alt : Travis CI https://github.com/travis-ci
  15. 15. Engineering debugging • Chrome developer tool – Eclipse based • Node-inspector – Browser based
  16. 16. Engineering when to use nodejs • When to use Node.js: • Use Node.js to: • Build a (soft) real-time social app like Twitter or a chat app. • Build high-performance, high I/O, TCP apps like proxy servers, PaaS, databases, etc. • Build backend logging and processing apps. • Build great CLI apps similar to vmc-tool, and build tools such as ant or Make. • Add a RESTful API-based web server in front of an application server. • When NOT to use Node.js: • Node.js is not suitable for every application: • Mission-critical (hard) real-time apps like heart monitoring apps or those that are CPU-intensive. • For simple CRUD apps that don’t have any real-time or high-performance needs, Node.js does not provide much of an advantage over other languages. • Enterprise apps that might need some specific libraries for which there may not be a Node.js library yet. (However, you could build a polyglot app that uses Java in conjunction to Node.js to help with libraries.)
  17. 17. Companies using NodeJs • LinkedIn, mobile webapp • Ebay, data retrival gateway • Github, for downloads • Dow Jones & Company, for WJS social site • PayPal (moving every product & every site)
  18. 18. Refs and links • http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/ • http://www.slideshare.net/the_undefined/nodejs-best-practices-10428790 • http://www.slideshare.net/the_undefined/nodejs-a-practical-introduction-v2 • http://www.slideshare.net/oscarrenalias/nodejs-for-architects-openslava-2013
  19. 19. Getting started !! • git checkout https://github.com/joyent/node • ./configure && make && sudo make install • vi example.js • node example.js
  20. 20. Thanks ! • 刘立杰 Jay LJLU
  21. 21. More interesting… • CoffeeScript • Twitter Bower • Yeoman/grunt • phantomjs

×