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
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
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
350
デザインシステムが必須の時代に
yosuke_furukawa
PRO
2
250
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
360
Removing Corepack
yosuke_furukawa
PRO
9
2k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
3.2k
Strip Types と Storage
yosuke_furukawa
PRO
4
530
Module Harmony について
yosuke_furukawa
PRO
4
2k
Other Decks in Programming
See All in Programming
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
130
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
480
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
520
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
120
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
220
Oxlintはいいぞ(続)
yug1224
1
500
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
550
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
270
信頼性の目標を誰も求めてない
shubox
0
440
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.2k
仕様駆動開発の消費期限
watany
20
9.1k
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
530
Featured
See All Featured
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
370
30 Presentation Tips
portentint
PRO
1
380
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The Curse of the Amulet
leimatthew05
2
14k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
Statistics for Hackers
jakevdp
799
230k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
660
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.9k
Amusing Abliteration
ianozsvald
1
280
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