There's a new kid in town: node.js


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

There's a new kid in town: node.js

  1. 1. Theres a new kid in town and his name is NodeJS Mike Amundsen @mamund
  2. 2. Setting the Stage• Mike Amundsen• Goals• Non-Goals• Bottom Line
  3. 3. Mike Amundsen• Presenter, Architect, Programmer• Current Focus: "Hypermedia"• Book Project ...• Designing Hypermedia APIs with HTML5 and NodeJS - O’Reilly, late 2011
  4. 4. Goals• Introduce NodeJS• Talk about why NodeJS is "different"• See some NodeJS examples• Encourage you to try it out yourself
  5. 5. Non-Goals• Details of downloading and installing NodeJS• Defending NodeJS programming model• Learning Javascript• Writing modules or contributing to NodeJS
  6. 6. Bottom Line• NodeJS is not business as usual• Javscript is not the interesting part of NodeJS• NodeJS represents an emerging trend• You should try it!
  7. 7. WAIT...
  8. 8. We spend a lot of our time waiting...
  9. 9. WAIT...
  10. 10. For someone else to do stuff...
  11. 11. WAIT...
  12. 12. So we can get our stuff done.
  13. 13. WAIT...
  14. 14. And thats a waste of valuableresources.
  15. 15. And thats a bummer!
  16. 16. I wonder, is there another way to dothis?
  17. 17. Ryan Dahl sez "Yes!"
  18. 18. NodeJS
  19. 19. Why NodeJS is Different
  20. 20. Threads• Most Web frameworks use "threads" to handle work• One thread for each request• Multiple threads for concurrent execution• There is a limit to the number of threads• But as long as requests are short, its not a problem
  21. 21. It used to be pretty simple...• Local files• Local database• Single data source
  22. 22. But then along came the cloud...• Remote files (Amazon S3)• Remote data (SQL Azure)• Multiple data sources (Twitter, Flickr, Disqus, etc.)
  23. 23. All that stuff means more waiting...
  24. 24. And that means longer requests...
  25. 25. And thats a bummer!
  26. 26. So NodeJS does it another way• Scavenge the "wait states" as execution time• Use a single loop (queue)1. Execute a request2. Go to the next item in the queue3. Go to step 1• No more waiting!
  27. 27. Its called the Reactor Pattern
  28. 28. This works great for the cloudbecause...• Requests usually involve waiting• Requests are usually "side-effect free" (state-less)• Most of the "work" is done by someone else (remote servers)
  29. 29. There, I fixed it!
  30. 30. Wait a minute<g>; how do you codethis?
  31. 31. Getting started is easy...• Starting a request is no problem• But you need to be ready when the remote server is done• You need to register a location for the returning call
  32. 32. You need a "callback"
  33. 33. If only there was a programminglanguage that everyone already knewthat also handled callbacks easily...
  34. 34. Lets see...• Scheme• Erlang• Scala• C++• ...• Theres at least one more I know of...
  35. 35. There, I fixed it again!
  36. 36. Javascript is a logical choice for Node• Its already well-known (if not well-understood<g>)• There are multiple JS "engines" (Node uses V8)• Javascript already supports callbacks and closures
  37. 37. So, lets review...
  38. 38. So, lets review...NodeJS uses the Reactor Pattern (event loop) to takeadvantage of the extended wait-states that are now morecommon with cloud-based implementations.
  39. 39. So, lets review...NodeJS uses the Reactor Pattern (event loop) to takeadvantage of the extended wait-states that are now morecommon with cloud-based implementations.And NodeJS uses Javascript on the "front-end" because itsupports callbacks/closures, is readily available, and well-known.
  40. 40. Ok, lets see some code!
  41. 41. NodeJS code is pretty straightforward
  42. 42. NodeJS code is pretty straightforward
  43. 43. Creating an HTTP file server is easy.
  44. 44. Writing a file uploader is even easier.
  45. 45. You can write clients w/ Node, too.
  46. 46. NodeJS has a package system: npm
  47. 47. Node Package Manager
  48. 48. And lots of modules...
  49. 49. For building full-featured applications
  50. 50. Check out these resources...
  51. 51. Home Page & Discussion Group• NodeJS Site (• Discussion Group (!forum/nodejs)
  52. 52. Books & Tutorials• Hands On NodeJS (Pedro Teixeira)• Up and Running w/ Node (• NodeTuts (
  53. 53. Online Hosting• JSApp.US ( - *instant*• Joyent (• Nodester (• DotCloud (• NodeSocket ( *nya*• NodeJitsu ( *nya*
  54. 54. In Summary...
  55. 55. NodeJS• Based on the "Reactor Pattern"• Uses Javascript on the front-end• Is well-suited for cloud-based implementations• Completely Open-Source (free)• Built on Linux• Windows Native port soon• Represents a growing trend
  56. 56. Theres a new kid in town and his name is NodeJS Mike Amundsen @mamund