what's so special about node.js
TRANSCRIPT
![Page 2: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/2.jpg)
years of front-end programming evolution
now on server-side
![Page 3: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/3.jpg)
javascript
![Page 4: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/4.jpg)
Fundamental videography
Ryan Dahl at JS.Conf 2009 show his creature
http://jsconf.eu/2009/video_nodejs_by_ryan_dahl.htmland also this ... http://vimeo.com/9968301
![Page 5: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/5.jpg)
Fundamental videography
Douglas Crockford: “Crockford on JavaScript
Scene 6: Loopage” August 2010
http://www.yuiblog.com/blog/2010/08/30/yui-theater-douglas-crockford-crockford-on-javascript
-scene-6-loopage-52-min
![Page 6: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/6.jpg)
node.js is special
![Page 7: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/7.jpg)
What does
node.js, nginx, memcached
have in common ?
![Page 8: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/8.jpg)
a C librarycalledlibevent
![Page 9: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/9.jpg)
Apache vs Nginx
http://blog.webfaction.com/a-little-holiday-present
![Page 10: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/10.jpg)
Apache vs Nginx
http://blog.webfaction.com/a-little-holiday-present
![Page 11: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/11.jpg)
apache uses threads
nginx uses an event loop
![Page 12: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/12.jpg)
... it's a different approachon building servers ...
with differnt strenghts / weaknesses
event loop approach scales better when has to serve
many clients with requests that doesn't need
so much "data crunching" elaboartion, but a lot of I/O
![Page 13: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/13.jpg)
Ryan's idea! node.js is a thin layer
that glue 3 libraries togheter:
V8 js engine +
libev (event loop) +
libeio (async I/O)
![Page 14: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/14.jpg)
blocking I/O
historically all programming languageshave blocking I/O
![Page 15: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/15.jpg)
but, a problem arise:the very expensive "data processing machine" is not used in a very efficient
way
![Page 16: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/16.jpg)
multi user systems
use of timesharing, in order to make the same computer
multiuser
![Page 17: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/17.jpg)
in our modern"server side" code,
the same thing appens
how do we solve this?simple, we do the same thing.
We invented the Threads!
![Page 18: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/18.jpg)
but now the situation is like this
Help !!! web real-time, long running sockets ... I've sent the newsletter with 90% discount !!! traffic jam !
![Page 19: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/19.jpg)
has a different approach
![Page 20: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/20.jpg)
event loop approach
event loop is used from many years in:
gamesgraphical UIs
...servers
![Page 21: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/21.jpg)
single thread server
c1, c2, c3, c4 ---> S ---> I/O
![Page 22: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/22.jpg)
multi-thread server
c1 ---> T1 ---> I/Oc2 ---> T2 ---> I/Oc3 ---> T3 ---> I/Oc4 ---> T4 ---> I/O
![Page 23: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/23.jpg)
thread pool server
c9, c5, c1 ---> T1 ---> I/Oc10, c6, c2 ---> T2 ---> I/Oc11, c7, c3 ---> T3 ---> I/Oc12, c8, c4 ---> T4 ---> I/O
![Page 24: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/24.jpg)
event loop
c1 ---> ST --> async I/Oc2 ---> c3 ---> c4 ---> c5 ---> c6 ---> c7 ---> c8 ---> c9 ---> c10 ---> c11 ---> c12 --->
![Page 25: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/25.jpg)
so what's the point ...
also the browseris
mono-threadand works with an
event loop
![Page 26: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/26.jpg)
when we writesetTimeout('timeout_trigger()', 2000)
we're not creating a new thread!
(as sometimes I've heard ...)
but we're subscribing a new event,
which will run our callback,
2 seconds from now
![Page 27: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/27.jpg)
so ... why all this hype ?
who are the most expert professionals
in event driven programming
with non blocking I/O ?
![Page 28: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/28.jpg)
the one that do this from years!
front-end developers!
![Page 29: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/29.jpg)
accidental evolutionof a language
(video)http://www.yuiblog.com/blog/2010/08/30/
yui-theater-douglas-crockford-crockford-on-javascript-scene-6-loopage-52-min
![Page 30: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/30.jpg)
part 2
![Page 31: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/31.jpg)
Do we all jump on the node.js train?
maybe sometimes
but it's important to understand what are the
strenght of node
so we can know how and when to use it.
![Page 32: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/32.jpg)
alternatives ?
yes,
but we can talk about themnext time ... :)
![Page 33: What's so special about node.js](https://reader033.vdocuments.us/reader033/viewer/2022061502/5559ae85d8b42a5b2a8b51b4/html5/thumbnails/33.jpg)
weaknesses
monothread (?)(also principal strength point)
.. you've to follow the rules
non blocking operations,develop in evented style