World of Node.JS

1,852 views

Published on

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

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,852
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

World of Node.JS

  1. 1. Node.JS World<br />
  2. 2. Prerequisites<br />Browser<br />Account on http://c9.io<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 />socket.io: 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 />http://nodejs.org/<br />http://npmjs.org/<br />https://github.com/<br />http://vowsjs.org/<br />http://nowjs.com/<br />http://howtonode.org/<br />http://nodejs.ru/<br />

×