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 event-driven programming.
Search
Alexey Taktarov
May 07, 2012
Programming
5
450
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
React Hooks: Iteractivity in Functional Components (RU)
molefrog
0
26
Practical Serverless & Edge Computing
molefrog
2
210
Дизайн принципы для разработчиков. Может ли дизайн сделать наши программы лучше?
molefrog
0
130
Hooks in action: implementing a 1KB React router
molefrog
0
120
How to apply design principles in software engineering?
molefrog
0
170
Give a second change to Rails frontend!
molefrog
4
560
Heroes of Information Security
molefrog
4
170
Other Decks in Programming
See All in Programming
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
280
Ruby GitHub Packages
bkuhlmann
0
640
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
2
210
デフォルトにして至高、RubyMineの大好きな所
ruzia
0
880
見た目から始める生産性向上
ikumatadokoro
10
1.4k
ServerAction で Progressive Enhancement はどこまで頑張れるか? / progressive-enhancement-with-server-action
takefumiyoshii
6
440
AppRouter Panel Talk
yosuke_furukawa
PRO
1
470
Webアプリをできるだけコードを手書きしないで作ってみる
tomokusaba
2
180
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
1.1k
Elm Form Validation
bkuhlmann
0
520
Exploring the Implementation of “t.Run”, “t.Parallel”, and “t.Cleanup”
akarin
1
130
WebGLで始める コンピュータグラフィックス入門
heller77
0
300
Featured
See All Featured
Faster Mobile Websites
deanohume
300
30k
Optimizing for Happiness
mojombo
370
69k
Designing for Performance
lara
601
67k
Building Effective Engineering Teams - LeadDev
addyosmani
32
1.9k
Designing on Purpose - Digital PM Summit 2013
jponch
111
6.5k
Learning to Love Humans: Emotional Interface Design
aarron
267
39k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
Imperfection Machines: The Place of Print at Facebook
scottboms
261
12k
Debugging Ruby Performance
tmm1
70
11k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
126
32k
Statistics for Hackers
jakevdp
790
220k
Rebuilding a faster, lazier Slack
samanthasiow
74
8.2k
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