Introduction to node.js

3,701 views

Published on

Quick introduction to node.js on WebExpo 2010

Published in: Technology
  • Be the first to comment

Introduction to node.js

  1. 1. node.js Jakub Nesetril jakub.nesetril@gmail.com
  2. 2. Who Are You?
  3. 3. Who Are You? • JS
  4. 4. Who Are You? • JS • Ruby
  5. 5. Who Are You? • JS • Ruby • web
  6. 6. Who Are You? • JS • Ruby • web • what real language do you speak?
  7. 7. TOC
  8. 8. TOC • blocking vs. non-blocking intro
  9. 9. TOC • blocking vs. non-blocking intro • short introduction to node.js
  10. 10. TOC • blocking vs. non-blocking intro • short introduction to node.js • examples
  11. 11. TOC • blocking vs. non-blocking intro • short introduction to node.js • examples • Q&A
  12. 12. Tags
  13. 13. Tags • #javascript , #v8 , #ssjs
  14. 14. Tags • #javascript , #v8 , #ssjs • #event-oriented
  15. 15. Tags • #javascript , #v8 , #ssjs • #event-oriented • #high-performance
  16. 16. Tags • #javascript , #v8 , #ssjs • #event-oriented • #high-performance • #asynchronous , #non-blocking
  17. 17. Tags • #javascript , #v8 , #ssjs • #event-oriented • #high-performance • #asynchronous , #non-blocking • #low-level
  18. 18. Tags • #javascript , #v8 , #ssjs • #event-oriented • #high-performance • #asynchronous , #non-blocking • #low-level • #fun!
  19. 19. What’s missing?
  20. 20. Tags • #javascript , #v8 , #ssjs • #event-oriented • #high-performance • #asynchronous , #non-blocking • #low-level • #stable , #mature (not!)
  21. 21. (non-) Blocking IO
  22. 22. (non-) Blocking IO • var rows = db.query(“SELECT * FROM…)
  23. 23. (non-) Blocking IO • var rows = db.query(“SELECT * FROM…) • rows.forEach…
  24. 24. (non-) Blocking IO • db.query(“SELECT * FROM…”, function(rows) { rows.forEach… });
  25. 25. Why isn’t everybody doing it?
  26. 26. Why isn’t everybody doing it? • non-blocking can be hard
  27. 27. Why isn’t everybody doing it? • non-blocking can be hard • JS is an ideal language / community for this
  28. 28. Why isn’t everybody doing it? • non-blocking can be hard • JS is an ideal language / community for this • Ajax / DOM has taught events to millions of people
  29. 29. Why isn’t everybody doing it? • non-blocking can be hard • JS is an ideal language / community for this • Ajax / DOM has taught events to millions of people • node.js = network servers in JS
  30. 30. Example 1
  31. 31. Design Principles
  32. 32. Design Principles • non-blocking - every IO must take callback
  33. 33. Design Principles • non-blocking - every IO must take callback • API should be familiar to client-side JS programmers ans old school UNIX hackers
  34. 34. Design Principles • non-blocking - every IO must take callback • API should be familiar to client-side JS programmers ans old school UNIX hackers • built-in support for HTTP, DNS, TLS
  35. 35. Design Principles • non-blocking - every IO must take callback • API should be familiar to client-side JS programmers ans old school UNIX hackers • built-in support for HTTP, DNS, TLS • support advanced features (chunked encoding, pipelining, hanging requests for websockets etc.)
  36. 36. Example 2
  37. 37. Ecosystem
  38. 38. Ecosystem • node modules (CommonJS)
  39. 39. Ecosystem • node modules (CommonJS) • npm
  40. 40. Ecosystem • node modules (CommonJS) • npm • connect & express
  41. 41. Ecosystem • node modules (CommonJS) • npm • connect & express • node-inspector
  42. 42. Ecosystem • node modules (CommonJS) • npm • connect & express • node-inspector • bounce
  43. 43. Advanced Topics
  44. 44. Advanced Topics • WebSockets
  45. 45. Advanced Topics • WebSockets • Server-side DOM
  46. 46. Advanced Topics • WebSockets • Server-side DOM • Performance
  47. 47. Advanced Topics • WebSockets • Server-side DOM • Performance • Hosting
  48. 48. NodeKnockout
  49. 49. Q&A

×