Your SlideShare is downloading. ×
0
Introduction to Node.js  Sudar Muthu (@sudarmuthu)      Research Engineer           Yahoo! Labs    http://github.com/sudar...
Agenda   What Node.JS is not   What is Node.JS   Why Node.JS?   Using Node.JS    ›   As a interactive shell    ›   As ...
Node.JS is not …   Ruby on Rails   Django   Codeigniter   CakePHP    Node.JS is bare bone and the community are making...
What is Node.JS JavaScript Programming Environment for creating highly  scalable network programs Provides Evented, non-...
What is Evented I/O
Single thread Synchronous I/O
Single thread Synchronous I/O
Multi thread Synchronous I/O
Multi thread Synchronous I/O
You can throw in more servers, but  that will cost you lot of money.
Synchronous I/O
Synchronous I/O
Synchronous I/O
Single thread Asynchronous I/O
Why Node.JS?So, code like thisvar result = db.query("select..");// use resulteither blocks the entire process orimplies mu...
Why Node.JS?But code like thisdb.query("select..", function (result) {    // use result});allows the program to return to ...
Demo of Callback// execute the callback after 2 secondssetTimeout(function () {   console.log("World!");}, 2000);// print ...
Using Node.JS Install Node.JS Install NPM Install other modules you want by doingnpm install <module_name> You are goo...
Node.JS – as an interactive shellSimilar to Python’s shell$> node>3+14> true != falsetrue>.help>.exit
Node.JS – As a servervar http = require(http); // require the http module// create a serverhttp.createServer(function (req...
Node.JS – As a clientvar http = require(http); // require the needed modules// make the request objectvar request = http.r...
Core Modules   Processes   Filesystem   Networking   UtilitiesThe entire list can be found at http://nodejs.org/api/
Core Modules - ProcessesNode allows you to analyze your process and manage external processAvailable Modules process chi...
Core Modules - FilesystemLow level API to manipulate filesAvailable Modules fs pathCode Samples: https://github.com/suda...
Core Modules - Networking Available Modules    net    dgram    http    tls    https    dns Code Samples: https://git...
Core Modules - Utilities Provides utility methods Available Modules  console  util Code Samples: https://github.com/suda...
Node.JS is useful for..   Writing highly concurrent server applications   Sharing application logic between server and c...
Terminologies   NPM – Package manager (like apt-get)   Modules – Plugins or add-ons for Node.JS   Express – MVC framewo...
Links http://github.com/sudar/node.js-samples (all code samples  used in this talk) http://nodejs.org http://npmjs.org...
Workshop
Express JS   Basic web framework   Runs on top of node.js   Provides routing and redirection helpers   Dynamic view he...
Hello World Express Apphttps://github.com/sudar/node.js-samples/tree/master/express/hello-world
Square Things App   Allows you to choose the color of a square region   A very simple server implementation   A very si...
Thank you
Introduction to node.js GDD
Introduction to node.js GDD
Introduction to node.js GDD
Introduction to node.js GDD
Upcoming SlideShare
Loading in...5
×

Introduction to node.js GDD

6,224

Published on

Slides from my workshop about node.js which I conducted in Girl Geek Dinner Bangalore. More details at http://sudarmuthu.com/blog/introduction-to-node-js-at-yahoo-girl-geek-dinner

Published in: Technology
2 Comments
12 Likes
Statistics
Notes
  • Just use `node client.js`. You can also change the url you are hitting in the client.js file.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • hi, I just started developing on node.js. The server can be run by `node server.js`. But I couldn't get how to run the client side js. Can somebody help me out?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
6,224
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
128
Comments
2
Likes
12
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to node.js GDD"

  1. 1. Introduction to Node.js Sudar Muthu (@sudarmuthu) Research Engineer Yahoo! Labs http://github.com/sudar http://sudarmuthu.com
  2. 2. Agenda What Node.JS is not What is Node.JS Why Node.JS? Using Node.JS › As a interactive shell › As a Server › As a Client Common Modules Terminologies Workshop
  3. 3. Node.JS is not … Ruby on Rails Django Codeigniter CakePHP Node.JS is bare bone and the community are making stuff like Express, connect etc.
  4. 4. What is Node.JS JavaScript Programming Environment for creating highly scalable network programs Provides Evented, non-blocking I/O Built on top of V8 engine Supports C/C++ based addons Supports CommonJS Module format Is fast .. in fact very fast. Similar to Event machine in Ruby or Twisted in Python
  5. 5. What is Evented I/O
  6. 6. Single thread Synchronous I/O
  7. 7. Single thread Synchronous I/O
  8. 8. Multi thread Synchronous I/O
  9. 9. Multi thread Synchronous I/O
  10. 10. You can throw in more servers, but that will cost you lot of money.
  11. 11. Synchronous I/O
  12. 12. Synchronous I/O
  13. 13. Synchronous I/O
  14. 14. Single thread Asynchronous I/O
  15. 15. Why Node.JS?So, code like thisvar result = db.query("select..");// use resulteither blocks the entire process orimplies multiple execution stacks (threads).
  16. 16. Why Node.JS?But code like thisdb.query("select..", function (result) { // use result});allows the program to return to the event loop immediately. No more unnecessary threads.
  17. 17. Demo of Callback// execute the callback after 2 secondssetTimeout(function () { console.log("World!");}, 2000);// print in consoleconsole.log("Hello");https://github.com/sudar/node.js-samples/blob/master/callback.js
  18. 18. Using Node.JS Install Node.JS Install NPM Install other modules you want by doingnpm install <module_name> You are good to go(This setup is already done for you. Use the Ubuntu image in thepen drive)
  19. 19. Node.JS – as an interactive shellSimilar to Python’s shell$> node>3+14> true != falsetrue>.help>.exit
  20. 20. Node.JS – As a servervar http = require(http); // require the http module// create a serverhttp.createServer(function (req, res) { // call this function when a request is received res.writeHead(200, { Content-Type: text/plain }); // send this as part of the response res.end(Hello Worldn);}).listen(1337, "127.0.0.1"); // listen on port 1337// debug informationconsole.log(Server running at http://127.0.0.1:1337/);https://github.com/sudar/node.js-samples/blob/master/http-server.js
  21. 21. Node.JS – As a clientvar http = require(http); // require the needed modules// make the request objectvar request = http.request({ host: sudarmuthu.com, port: 80, path: /, method: GET});// assign callbacksrequest.on(response, function (response) { console.log(Response Status Code: + response.statusCode); response.on(data, function (data) { console.log(Body: + data); });});https://github.com/sudar/node.js-samples/blob/master/http-client.js
  22. 22. Core Modules Processes Filesystem Networking UtilitiesThe entire list can be found at http://nodejs.org/api/
  23. 23. Core Modules - ProcessesNode allows you to analyze your process and manage external processAvailable Modules process child_processCode samples: https://github.com/sudar/node.js- samples/blob/master/process.js
  24. 24. Core Modules - FilesystemLow level API to manipulate filesAvailable Modules fs pathCode Samples: https://github.com/sudar/node.js- samples/blob/master/filesystem.js
  25. 25. Core Modules - Networking Available Modules  net  dgram  http  tls  https  dns Code Samples: https://github.com/sudar/node.js- samples/blob/master/dns.js
  26. 26. Core Modules - Utilities Provides utility methods Available Modules  console  util Code Samples: https://github.com/sudar/node.js- samples/blob/master/console.js
  27. 27. Node.JS is useful for.. Writing highly concurrent server applications Sharing application logic between server and client Peer-to-peer web applications using websockets Real-time applications
  28. 28. Terminologies NPM – Package manager (like apt-get) Modules – Plugins or add-ons for Node.JS Express – MVC framework (like RoR) Jade – Template Engine (like Smarty) Socket.IO – A websockets Library
  29. 29. Links http://github.com/sudar/node.js-samples (all code samples used in this talk) http://nodejs.org http://npmjs.org http://expressjs.com http://socket.io
  30. 30. Workshop
  31. 31. Express JS Basic web framework Runs on top of node.js Provides routing and redirection helpers Dynamic view helpers Has support for sessions Focus on high performance
  32. 32. Hello World Express Apphttps://github.com/sudar/node.js-samples/tree/master/express/hello-world
  33. 33. Square Things App Allows you to choose the color of a square region A very simple server implementation A very simple client MVC implementation Uses node.js on the server Uses Y.App implementation on the clienthttps://github.com/ericf/square-thing-app
  34. 34. Thank you
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×