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
440
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
25
Practical Serverless & Edge Computing
molefrog
2
200
Дизайн принципы для разработчиков. Может ли дизайн сделать наши программы лучше?
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
550
Heroes of Information Security
molefrog
4
170
Other Decks in Programming
See All in Programming
チーム力を高めるスクラム実践法:カンバン公開と課題攻略について - ニフティのスクラムトーク Vol. 2 - NIFTY Tech Talk #18
niftycorp
PRO
1
110
Changed Rules: Architectures with Lightweight Stores
manfredsteyer
PRO
0
240
Java 22 Overview
kishida
1
180
Goのmultiple errorsについて (2024年4月版)
syumai
1
330
エンターテイメント業界で利用されるAWS
demuyan
0
210
Rails と人魚の話/rails-and-mermaid
sanfrecce_osaka
0
100
Milestoner
bkuhlmann
1
410
Git Rebase
bkuhlmann
11
1.6k
MetricKitで予期せぬ終了を検知する話 / Detect unexpected termination with MetricKit
nekowen
0
180
CQRS/ES avec Symfony, c’est (trop) bien !
jeremyfreeagent
1
640
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
160
Ruby Pattern Matching
bkuhlmann
0
920
Featured
See All Featured
A Philosophy of Restraint
colly
196
16k
YesSQL, Process and Tooling at Scale
rocio
163
13k
A designer walks into a library…
pauljervisheath
199
23k
Being A Developer After 40
akosma
56
580k
The Cult of Friendly URLs
andyhume
74
5.7k
What’s in a name? Adding method to the madness
productmarketing
PRO
15
2.6k
Typedesign – Prime Four
hannesfritz
36
2.1k
Stop Working from a Prison Cell
hatefulcrawdad
266
19k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
1
3.4k
Raft: Consensus for Rubyists
vanstee
132
6.3k
Automating Front-end Workflow
addyosmani
1355
200k
Scaling GitHub
holman
457
140k
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