Successfully reported this slideshow.

World of Node.JS


Published on

Small, no-design presentation for my VIP practice session at the nerdcamp, 24 april 2011.

Published in: Technology
  • Be the first to comment

World of Node.JS

  1. 1. Node.JS World<br />
  2. 2. Prerequisites<br />Browser<br />Account on<br />
  3. 3. Why JavaScript matters<br />Large pool of programmers<br />Large corporations throw a lot of money at making it more efficient. V8 (in Google Chrome) is one of the fastest dynamic engines. <br />Universal language (every web programmer knows it - ruby, python, php etc.)<br />
  4. 4. Node.JS<br />It is a set of non-blocking APIs for the OS, built on top of V8 interpreter.<br />It is a command line tool, mostly for Linux. You download a tarball, compile and install the source.<br />It let's you run JavaScript programs by typing 'node my_app.js' in your terminal.<br />HTTP/S is a first-class citizen. <br />CommonJS module system.<br />
  5. 5. Asynchronous, Event-based<br />JavaScript is single threaded<br />Everything runs in parallel, except your code.<br />You don't have to worry about code accessing the same data structures at the same time.<br />Node.JS uses async mechanisms of the underlying OS (epoll, libeio)<br />It’s natural to write it in JS (closures, etc).<br />
  6. 6. Hello world using Node.js<br />
  7. 7. Why it’s good<br />It’s JavaScript – mentioned before + <br />Code reuse (shared codebase with client side)<br />Modern, unified language<br />CommonJS module system <br />Large, easily accessible library of modules<br />
  8. 8. Why it’s good<br />Efficiency (time+memory): no thread switching/process switching costs + epoll + libev + libeio<br />Conceptually easier - no multithreading issues.<br />Massive concurrency.<br />
  9. 9.
  10. 10. Fast development pace<br />Large active community <br />1754 packages/libraries in popular package manager<br />~150 coders in Russia<br />
  11. 11. Alternatives<br />Python: Twisted, Tornado<br />Erlang: erlycomet<br />Ruby: EventMachine<br />Perl: POE<br />Java: JBossNetty (based on java.nio)<br />
  12. 12. Most notable modules<br />npm: packager<br />connect/express/ejs/jade/stylus: web stack<br /> real-time communication with browser (WebSockets, etc)<br />coffee-script: JavaScript 2.0<br />jsdom+vows+zombie: Unit tests + browser emulation<br />
  13. 13. Socket.IO<br />Library to simplify implementation of realtime communication with different browsers.<br />WebSockets<br />Flash<br />Long polling<br />Polling<br />Users don’t need to know about it.<br />A lot of connections can be kept due to Node.<br />
  14. 14. Unsolved problems<br />No complete easy, standard solution for servers<br />Single thread -> single core. No standard solution for CPU-intensive tasks.<br />
  15. 15. Additional reading<br /><br /><br /><br /><br /><br /><br /><br />