Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Got Milk? A short introduction to node.js and e...
Search
Alexey Taktarov
May 07, 2012
Programming
5
470
Got Milk? A short introduction to node.js and event-driven programming.
A short introduction to node.js and event-driven programming.
Alexey Taktarov
May 07, 2012
Tweet
Share
More Decks by Alexey Taktarov
See All by Alexey Taktarov
The challenges of web apps: what we’ve solved and what’s next?
molefrog
0
14
React Hooks: Iteractivity in Functional Components (RU)
molefrog
0
54
Practical Serverless & Edge Computing
molefrog
2
240
Дизайн принципы для разработчиков. Может ли дизайн сделать наши программы лучше?
molefrog
0
130
Hooks in action: implementing a 1KB React router
molefrog
0
130
How to apply design principles in software engineering?
molefrog
0
240
Give a second change to Rails frontend!
molefrog
4
640
Heroes of Information Security
molefrog
4
180
Other Decks in Programming
See All in Programming
42 best practices for Symfony, a decade later
tucksaun
1
180
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
200
Go の GC の不得意な部分を克服したい
taiyow
2
760
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
250
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
useSyncExternalStoreを使いまくる
ssssota
6
1k
Haze - Real time background blurring
chrisbanes
1
500
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
890
MCP with Cloudflare Workers
yusukebe
2
220
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
200
선언형 UI에서의 상태관리
l2hyunwoo
0
130
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
RailsConf 2023
tenderlove
29
940
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Writing Fast Ruby
sferik
628
61k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Designing for humans not robots
tammielis
250
25k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Transcript
Got milk?
None
milk = dear_son.please_buy_a_milk();
milk = dear_son.please_buy_a_milk();
milk = dear_son.please_buy_a_milk(); dear_son.thank_you(); milk.drink();
milk = dear_son.please_buy_a_milk(); dear_son.thank_you(); milk.drink(); Blocking operations
milk = dear_son.please_buy_a_milk();
milk = dear_son.please_buy_a_milk(); do_cleanup(); do_something_else();
milk = dear_son.please_buy_a_milk(); do_cleanup(); do_something_else(); /* ? dear_son.here_is_your_milk(); */ Non-Blocking
operations
Event-Loop
milk = dear_son.please_buy_a_milk(); /* Event loop starts - while(…) */
if( dear_son.milk_ready() ) break; do_some_cleanup(); /* Event loop ends */ Event-Loop
In terms of: 1. OS ( process, threads scheduling) 2.
Application ( event-loops, overlapped system calls, callbacks )
OS can handle it. So why should I know about
event-loops and other sh!t?!
That’s why
Introducing Node.Js! Event-driven I/O server-side JavaScript framework based on V8
Why Javascript? 1. It’s awesome 2. It’s simple 3. It’s
popular 4. V8 is really fast 5. Built-in support for callbacks, lambdas, closures and other magic
setTimeout(function() { console.log('Hello, '); }, 1000); console.log(' World!'); Dummy example
#1
Dummy example #2 var http = require(‘http’); http.createServer(function (req, res)
{ res.writeHead(200, {'Content-Type': ‘text/plain'}); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at port 1337');
Web-Server | CGI | php, perl, python, etc.
Node.Js (all-in-one: web-server, caching, parsing, templating, data-storing, doing-a-sandwich)
Features 1. Clustering 2. Packages: web-frameworks, DB, graphics, BNF parsers,
unit- testing, … + package manager 3. Cloud 9 IDE (runs in browser)
Problems Asynchronous logic hell!
Problems Asynchronous logic hell! 1. Using helper modules (deferred, async,
node-fibers) 2. Program is Finite State Machine
The main problem Node.Js is very young, so be careful!
Use it just-for-fun!
Resources 1. “UNIX internals” by U.Vahalia 2. “Thinking Asynchronous in
C++” by author of boost::asio http://blog.think-async.com/ 3. Online npm repository http://search.npm.js 4. Cloud 9 IDE http://c9.io
Have a nice milk! Speaker: Taktarov A. Drawings: Taktarov E.
molefrog[at]gmail.com