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
mercury/mithril.js
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Yosuke Furukawa
PRO
April 24, 2015
Programming
11k
14
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
mercury/mithril.js
react meetup #1 資料
Yosuke Furukawa
PRO
April 24, 2015
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
デザインシステムが必須の時代に
yosuke_furukawa
PRO
2
240
Node.js, Deno, Bun 最新動向とその所感について
yosuke_furukawa
PRO
10
5.3k
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
1
4.8k
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
350
Removing Corepack
yosuke_furukawa
PRO
9
2k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
3.1k
Strip Types と Storage
yosuke_furukawa
PRO
4
520
Module Harmony について
yosuke_furukawa
PRO
4
1.9k
LTのやり方
yosuke_furukawa
PRO
16
3k
Other Decks in Programming
See All in Programming
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
350
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
330
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
2
600
act2-costs.pdf
sumedhbala
0
120
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
160
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
180
1年で人数1.5倍、PR数5.5倍増。 品質とアウトカムはどうなったか、 何が効いたか
ike002jp
0
140
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
9.2k
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
320
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
340
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
150
どこまでゆるくて許されるのか
tk3fftk
0
510
Featured
See All Featured
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.3k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.5k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
190
Technical Leadership for Architectural Decision Making
baasie
3
440
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
45k
Ruling the World: When Life Gets Gamed
codingconduct
0
290
Navigating Weather and Climate Data
rabernat
0
390
Practical Orchestrator
shlominoach
191
11k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
360
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Transcript
mercury / mithril.js @yosuke_furukawa
@yosuke_furukawa Node.jsϢʔβʔάϧʔϓද / DeNAॴଐ
ࠓͷςʔϚ
Performance
Introduction To React (@hokaccha) https://speakerdeck.com/hokaccha/introduction-to-react
Introduction To React (@hokaccha) https://speakerdeck.com/hokaccha/introduction-to-react 3FBDUࣗͦ Μͳʹ͘ͳ͍ #BDLCPOFͰ෦࠶ඳ ը͢Δํ͕͍
ຊͷͱ͜ΖͲ͏ͩΖ͏͔
lhorie TodoMVC Peformance http://lhorie.github.io/todomvc-perf-comparison/todomvc-benchmark/
lhorie TodoMVC Peformance http://lhorie.github.io/todomvc-perf-comparison/todomvc-benchmark/ ͔֬ʹͦ͜·Ͱ ͘ͳ͍
lhorie TodoMVC Peformance http://lhorie.github.io/todomvc-perf-comparison/todomvc-benchmark/ ͔֬ʹͦ͜·Ͱ ͘ͳ͍ .FSDVSZ .JUISJM
ReactΑΓߴͳ mercuryͱmithrilͲ͏͍͏ ߟ͑ํͰߴԽ͍ͯ͠Δͷ͔
ReactͷඳըΞϧΰϦζϜ
ReactͷඳըΞϧΰϦζϜ Before After ֤͝ͱʹ Node ͷมߋ͕ଘࡏ͢Δ͔֬ೝ͢Δ (Level By Level diff)
ReactͷඳըΞϧΰϦζϜ Before After ҰͭҰͭͷNodeʹID͕ৼΒΕ͓ͯΓɺͦͷIDΛݩ ʹॱংͷಉҰੑɺ༰ͷࠩΛݟͯdiffΛΔ ID ID ID ID ID
ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID ID
ReactͷඳըΞϧΰϦζϜ ঢ়ଶมߋ TFU4UBUF ͞ΕΔͱEJSUZqBH͕ ཱͪɺࢠϊʔυ͕࠶ඳըରʹͳΔ
ReactͷඳըΞϧΰϦζϜ /PEFʹରͯ͠ঢ়ଶมߋ TFU4UBUF ͞ΕΔͱEJSUZqBH͕ ཱͪɺࢠϊʔυશ͕ͯ࠶ඳըରʹ ͳΔ
ReactͷඳըΞϧΰϦζϜ ࢠϊʔυͷҰ෦࠶ඳըͤͨ͘͞ͳ ͍߹ TIPVME$PNQPOFOU6QEBUFΛ͑ ࠶ඳը͠ͳ͘ͳΔɻ
mithrilͷΞϓϩʔν
࠶ඳըͷܭࢉճΛݮΒ͢
var doStuff = function() { m.startComputation(); setTimeout(function() { console.log("hello"); m.endComputation();
}, 1000); }; mithrilͷΞϓϩʔν
var doStuff = function() { m.startComputation(); setTimeout(function() { console.log("hello"); m.endComputation();
}, 1000); }; mithrilͷΞϓϩʔν counter: 0
var doStuff = function() { m.startComputation(); setTimeout(function() { console.log("hello"); m.endComputation();
}, 1000); }; mithrilͷΞϓϩʔν counter: 1 TUBSU$PNQVUBUJPOͰ࠶ඳ ըΧϯλΛ܁Γ্͛
var doStuff = function() { m.startComputation(); setTimeout(function() { console.log("hello"); m.endComputation();
}, 1000); }; mithrilͷΞϓϩʔν counter: 0 FOE$PNQVUBUJPOͰ࠶ඳը ΧϯλΛԼ͛Δ
var doStuff = function() { m.startComputation(); setTimeout(function() { console.log("hello"); m.endComputation();
}, 1000); }; mithrilͷΞϓϩʔν counter: 0 ࠶ඳըΧϯλ͕ʹͳͬ ͨΒ࠶ඳըΛ࣮ߦ
var doStuff = function() { m.startComputation(); jQuery.ajax("/something").done(function() { doStuff(); jQuery.ajax("/another").done(function()
{ doMoreStuff(); jQuery.ajax("/more").done(function() { if (callback) callback(); m.endComputation(); }); }); }); }; mithrilͷΞϓϩʔν ඇಉظॲཧ͕ෳճ࣮ߦ͞Εͨ࣌Ͱ͋ͬͯɺ ࠶ඳըΛ࠷ޙ·ͰͨͤΔ͜ͱ͕Ͱ͖Δɻ
setInterval(function(){ m.redraw(true); counter++; }, 100); mithrilͷΞϓϩʔν ஞ࣍తʹ࠶ඳըΛ͍ͨ͠߹ redrawΛ໌ࣔత ʹݺͿ
ͪͳΈʹ mithrilͷৄࡉ @shibu_jp ͕ৄ͘͠ڭ͑ͯ͘Ε·ͨ͠ɻ
mercuryͷΞϓϩʔν
࠶ඳըճΛݮΒ͢ & vdom treeͷ୳ࡧൣғΛݮΒ͢
࠶ඳըճΛݮΒ͢ & vdom treeͷ୳ࡧൣғΛݮΒ͢ vdom-thunk
VDOM ͷ tree ͷ୳ࡧൣғΛݶ ఆ͢Δ QBSUJBMΛ࡞ͬͯͦ͜ҎԼΛݟΔɻ IFBEFSʹ͕ؔ͋ΔͳΒͦ͜ ҎԼ͔͠ݟͳ͍
VDOM ͷ tree ͷ୳ࡧൣғΛݶ ఆ͢Δ var Thunk = require("vdom-thunk") function
render(state) { return h('div', [ Thunk(header, state.head), // headͷঢ়ଶ͕มΘͬͨΒheader͚ͩݟΔ main(), Thunk(footer, state.foot) // footͷঢ়ଶ͕มΘͬͨΒfooter͚ͩݟΔ ]) } function header(head) { ... } function main() { ... } function footer(foot) { ... } શؔ͘ͷͳ͍ྖҬΛ୳ࡧ͢Δ͜ͱΛͳ͘͢ (ͳΜ͔ͪΐͬͱͬͨײ…)
ͭ·Γ
·ͱΊ • React͕ͬͯΔ͜ͱઃܭͱੑೳͷڞଘ • ͞ΒʹੑೳΛ্͛ΔࣄͰ͖Δɻ • ͨͩ͠ɺ1͍ͭϨΠϠʔͰͷॲཧ͕ٻΊΒΕΔɻ • ReactͰ͍ͱײ͡ΔΑ͏ͳϦονͳΣϒΞϓϦ έʔγϣϯΛ࡞Γ͍ͨͳΒmercury/mithrilΛࢼ͢ͷ
ྑ͍͔ɻ
see also • http://calendar.perfplanet.com/2013/diff/ • https://github.com/Raynos/mercury • http://lhorie.github.io/todomvc-perf- comparison/todomvc-benchmark/ •
http://lhorie.github.io/mithril/ • @shibu_jp