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
490
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
56
React Hooks: Iteractivity in Functional Components (RU)
molefrog
0
77
Practical Serverless & Edge Computing
molefrog
2
250
Дизайн принципы для разработчиков. Может ли дизайн сделать наши программы лучше?
molefrog
0
140
Hooks in action: implementing a 1KB React router
molefrog
0
150
How to apply design principles in software engineering?
molefrog
0
260
Give a second change to Rails frontend!
molefrog
4
680
Heroes of Information Security
molefrog
4
180
Other Decks in Programming
See All in Programming
generative-ai-use-cases(GenU)の推しポイント ~2025年4月版~
hideg
1
390
データと事例で振り返るDevin導入の"リアル" / The Realities of Devin Reflected in Data and Case Studies
rkaga
1
1k
flutter_kaigi_mini_4.pdf
nobu74658
0
150
オープンソースコントリビュート入門
_katsuma
0
130
生成AI時代のフルスタック開発
kenn
3
400
REALITY コマンド作成チュートリアル
nishiuriraku
0
120
ComposeでのPicture in Picture
takathemax
0
130
KANNA Android の技術的課題と取り組み
watabee
1
460
Cursorを活用したAIプログラミングについて 入門
rect
0
190
Serving TUIs over SSH with Go
caarlos0
0
650
Ruby で作る RISC-V CPU エミュレーター / RISC-V CPU emulator made with Ruby
hayaokimura
5
1k
Designing Your Organization's Test Pyramid ( #scrumniigata )
teyamagu
PRO
5
1.3k
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
336
57k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
Docker and Python
trallard
44
3.4k
Bash Introduction
62gerente
613
210k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
5
600
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
14
1.5k
Documentation Writing (for coders)
carmenintech
71
4.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Raft: Consensus for Rubyists
vanstee
137
6.9k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
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