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.

Node.js for beginner

429 views

Published on

Node.js introduction for beginner.

Published in: Technology

Node.js for beginner

  1. 1. Node.js For Beginner Sarunyhot Suvannachoti (Kao) Software Engineer @ Jitta.com
  2. 2. What is Node.js • Created by Ryan Dahl in 2009 • Server-side JavaScript • Uses V8 is an open source JavaScript engine developed by Google.Its written in C++ and is used in Google Chrome Browser • Event-driven with Non-blocking I/O • Single threaded • Current Version is 4.0.0
  3. 3. Node.js Foundation Fork of Node.js +
  4. 4. Node.js Event loop
  5. 5. Blocking I/O
  6. 6. Blocking I/O 10 Sec 30 Sec
  7. 7. Blocking I/O 30 Sec 10 Sec Sum = 30 + 10
  8. 8. Non-Blocking I/O
  9. 9. Non-Blocking I/O Run parallel min=10 max=30
  10. 10. Asynchronous programming techniques
  11. 11. The two model of Async Processing • Callback function generally define logic for one-off responses.– Ex: perform a database query • Event listeners, are essentially callbacks that are associated with a conceptual entity (an event).–Respond to repeating events –EX: HTTP server emits a request event when an HTTP request is made
  12. 12. What is callback function? • A callback is a function,passed as an argument to an asynchronous function • It describes what to do after the asynchronous operation has completed Callback function
  13. 13. What is event-listeners?
  14. 14. What is event-listeners?
  15. 15. Stream
  16. 16. When to use Node.js? • Creating streaming based real-time services,web chat applications,static file servers etc. • Applications that have a lot of concurrent connections and each request only needs very few CPU cycles
  17. 17. The Essence of Node • JavaScript on the Server • More than server-side JavaScript • Fabulous framework • Asynchronous programming • Module-driven development
  18. 18. It’s is JavaScript • Easy to learn • Lets you unify your client/server logic • Productivity • Already in the Enterprise (Paypal,Netflix,Walmart,IBM)
  19. 19. More than server-side JavaScript • Web server • Robot controller (tessel.io) • Command line application • Proxy server • Music machine • Desktop application tooling: NW.js
  20. 20. Desktop Application (torrent)
  21. 21. Desktop Application (editor)
  22. 22. Desktop Application (music)
  23. 23. Desktop Application (game)
  24. 24. Fabulous framework • Express • Restify (for building REST APIs, automatic DTrace support) • Hapi (configuration-centric framework) • Sails (fast production-ready) • Meteor (realtime application)
  25. 25. Module-driven development • Node Package Manager (NPM) • 180,000++ packages • 90,000,000++ downloads per day • Simplicity • Decoupled and reusable coding
  26. 26. The state of the registry • 1400MM package downloads last month • 150,000 packages in the registry • `Node` is moving faster than `Node.js`
  27. 27. Module-driven development • npm focused on module-driven development • ES6 Modules • Module-driven development for the browser • Browser tools: Browserify
  28. 28. Module-driven development for the browser bower install moment --save npm install moment --save
  29. 29. DEMO
  30. 30. Where can learn more? • http://nodeschool.io • http://www.codewars.com • https://www.codeschool.com/courses/real-time-web-with-node-js • http://nodeup.com/

×