Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rust & Emscriptenの話
Search
Yosuke Onoue
November 21, 2015
Technology
250
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rust & Emscriptenの話
Yosuke Onoue
November 21, 2015
More Decks by Yosuke Onoue
See All by Yosuke Onoue
ネットワーク可視化の世界
likr
8
7.1k
Think About Front-end Web Development with Rust
likr
2
600
Yewにおけるoff-the-main-thread
likr
1
860
行政事業レビューデータの可視化 / Visualization of Japan's National Budget with JUDGIT!
likr
1
280
モダンJavaScript再入門 / Re-introduction to Modern JavaScript
likr
24
12k
Web-based Data Visualization with Rust and WebAssembly
likr
4
6.3k
Introduction to Graph Drawing
likr
0
570
20190707Ionic_Meetup.pdf
likr
0
500
About the end of the web
likr
2
580
Other Decks in Technology
See All in Technology
2026-09-11 【Snowflake World Tour Tokyo 2026】Snowflakeを起点に、AI Agentが自律稼働し続ける未来へ / Driving AI Agents with Snowflake
civitaspo
0
290
Where Is JetBrains AI Heading- — Central CLI, Air Alpha, and the Agentic Development Stack
x5gtrn
PRO
0
150
こんなアーキテクチャ図は嫌だ BEYOND THE TIME: 半年後の自分へ贈る15のメッセージ / 15 of Anti-pattern in AWS Architecture Diagrams
naospon
3
300
Driving AI Adoption Using In-House GPUs to Serve Qwen
po3rin
2
480
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
4
25k
SQL文一行も書けない人事がCortexもろもろを使って人事業務を楽にしてみる
ponponmikankan
1
210
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
180
Deploying a Full-Stack Bun-Native Framework on Cloudflare Workers
7nohe
0
130
なぜSRE・セキュリティは評価されないのか?守りの組織を事業成長エンジンに変えた実践
cscengineer
PRO
3
2.4k
Adaptive Warehouse を今すぐ導入すべき理由と迷ったときの判断基準
__allllllllez__
0
160
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
590
アプリをもっと"iOSアプリっぽく"する小さな工夫 / Small Touches That Make Your App Feel More Like an iOS App
matsuji
1
310
Featured
See All Featured
Writing Fast Ruby
sferik
630
63k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
4
620
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
320
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
320
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
240
RailsConf 2023
tenderlove
30
1.5k
Mind Mapping
helmedeiros
1
350
Code Review Best Practice
trishagee
74
20k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
The Curse of the Amulet
leimatthew05
2
14k
Transcript
Rust & Emscriptenͷ ͓ͷ͏͑ (@_likr) 2015/11/21 2016ͷAltJSʹ͍ͭͯޠΔձ
ࣗݾհ • ͓ͷ͏͑ ( @_likr ) • ՄࢹԽͷݚڀͱ͔ͬͯΔ • ng-kyotoͱGDG
KobeͰελοϑͬͯΔ • D3.jsɺAngularJSɺReactͱ͔ͬͯΔ
ҙ • ωλൃදͰ͢ • ͙͢ʹࣄͰ͑Δٕज़Ͱ͋Γ·ͤΜ • AngularGoogleςΫϊϩδʔͷ͋Γ·ͤΜ • AltJSͷ͋·Γ͋Γ·ͤΜ
ΦϨͷߟ͑ͨ࠷ڧͷ ࣍ੈϑϩϯτΤϯυ։ൃ ͓ͷ͏͑ (@_likr) 2015/11/21 2016ͷAltJSʹ͍ͭͯޠΔձ
Γ͍ͨ͜ͱ • େنɾߴͳWebϑϩϯτΤϯυΞϓϦͷ։ൃ (ܭࢉɾΞϧΰϦζϜͳͲͷΣΠτେ͖͍)
JavaScriptͷਐา • ClassesɺArrow functionsɺModules • DecoratorsɺAsync/Await • Type Annotations •
…
JavaScriptɺWebϖʔδΛνΧνΧͤ͞ΔͨΊ ͚ͩͷػೳ͔Β͠ɺେن։ൃՄೳͳ ख़ͨ͠ϓϩάϥϛϯάݴޠʹͳΓͭͭ͋Δ
ͰɺJavaScript͕ͭΒ͍໘·ͩ͋ΔΑͶʁ
ྫ͑ɺredux JavaScriptͷΦϒδΣΫτΛpureʹอͭͨΊʹɺ • Array.fromɺObject.assignΛͬͨίϐʔ • immutable.jsͷར༻ JavaScriptͰimmutabilityͷอূ͍͠ state action reducer
next state ෭࡞༻ͷͳ͍ؔ →stateͷมߋېࢭʂ immutability: ΦϒδΣΫτ͕มߋ͞Εͳ͍͜ͱ
όάͷԹচ • มߋ͍͚ͯ͠ͳ͍ͷมߋ • มߋͯ͠ҙຯͳ͍ͷมߋ • ΞΫηε͍͚ͯ͠ͳ͍ͷΞΫηε • ্هΛอূ্ͨ͠Ͱͷtestability
ܧ͗͠ܧ͗͠ͷݴޠ༷Ͱɺ ৽͍͠ύϥμΠϜʹै͢Δͷݶքʁ
େنͰߴͳWebϑϩϯτΤϯυΞϓϦΛ ࣮͍͢͠ݴޠʁ
͍ΖΜͳݴޠ… • CɺC++ɺJavaɺScalaɺGoɺ HaskellɺOCamlɺCoffeeScriptɺ TypeScriptɺElmɺHaxeɺClosure Scriptɺ…ʁ
Rust
Rust • https://www.rust-lang.org/ • Mozilla͕։ൃͨ͠γεςϜϓϩάϥϛϯάݴޠ • 20155݄ʹόʔδϣϯ1.0ϦϦʔε • ݱࡏόʔδϣϯ1.4 •
࠾༻ࣄྫɿ Servo (https://github.com/servo/servo)
Rustͷಛ • ࣮ߦ • ߴͳநԽͱޮతͳ࣮ߦΛཱ྆ • ϝϞϦηʔϑ • ϝϞϦͷྖҬ֎ΞΫηεϝϞϦϦʔΫΛࢭ •
εϨουηʔϑ • ϚϧνεϨουϓϩάϥϛϯάͷϛεΛࢭ
ݸਓతͳϝϦοτ • Garbage Collection͕ͳ͍ • ThreadɺSIMDΛඪ४ϥΠϒϥϦͰαϙʔτ • Web AssemblyͷରԠ͕༗
ࠓɺRustͰWebϑϩϯτΤϯυ։ൃ͕Ͱ͖Δͷ͔ʁ
Emscripten
Emscripten • http://emscripten.org/ • LLVM to JavaScript Compiler • C/C++ϓϩάϥϜΛJavaScriptʹม
• ࠷దԽΛ༗ޮԽ͢Δͱasm.jsΛग़ྗ • কདྷతʹWebAssemblyʹରԠ
rust-webplatform • https://github.com/tcr/rust-webplatform • DOM APIͷബ͍ϥούʔ • ηοτΞοϓεΫϦϓτ͖ • cargo-build
(https://github.com/AerialX/cargo-build) • rust-rt-minimal (https://github.com/AerialX/rust)
Hello World 1 extern crate webplatform; 2 3 fn main()
{ 4 let document = webplatform::init(); 5 6 let p = document.element_create("p").unwrap(); 7 p.html_append("hello world"); 8 9 let body = document.element_query("body").unwrap(); 10 body.append(&p); 11 12 webplatform::spin(); 13 }
զʑ͕ཉ͔ͬͨ͠ͷ͜Εͳͷ͔ʁ
ޮྑ͍։ൃͷͨΊʹϑϨʔϜϫʔΫ͕ඞཁͩʂ
Virtual DOMͬΆ͍ͷΛ࣮ͯ͠ΈΔ
RustͰVirtual DOM • ComponentఆٛͱRendererΛ͢Δ • Pure RustͷComponentͱɺ ϒϥβͱΓͱΓ͢ΔRenderer • Mithril(https://lhorie.github.io/mithril/)Λਅࣅ͢Δ
• ܰྔɺγϯϓϧ
࡞ͬͨ 29 pub fn v(tag: &str, attributes: Vec<Attribute>, children: Vec<Node>)
-> Node { 30 Node::Element(Element { 31 tag: String::from_str(tag), 32 attributes: attributes, 33 children: children 34 }) 35 } ཁૉ໊ɺଐੑɺࢠComponentΛड͚औͬͯComponentΛੜ͢Δؔ ComponentΛड͚औͬͯHTMLͷॻ͖ग़͠Λߦ͏ؔ 9 pub fn mount<'a, T: 'a + Component>( 10 document: Rc<RefCell<Document<'a>>>, 11 root: Rc<RefCell<HtmlNode<'a>>>, 12 component: Rc<RefCell<T>>) { 13 let target = root.borrow(); 14 target.html_set(""); 15 let node = component.borrow().render(); 16 render(document, target.deref(), node, root.clone(), component); 17 }
࠶Hello World 8 struct Main; 9 10 impl Component for
Main { 11 fn render(&self) -> Node { 12 v("div", 13 vec![attribute("class", text_value("hoge"))], 14 vec![ 15 v("p", vec![], vec![ 16 text_node("hello"), 17 ]), 18 v("p", vec![], vec![ 19 text_node("world"), 20 ]) 21 ] 22 ) 23 } 24 } 25 26 fn main() { 27 let main_component = Rc::new(RefCell::new(Main)); 28 let document = Rc::new(RefCell::new(webplatform::init())); 29 let body = Rc::new(RefCell::new(document.borrow().element_query("body").unwrap())); 30 vdom::mount(document.clone(), body.clone(), main_component.clone()); 31 webplatform::spin(); 32 } <div class="hoge"> <p>hello</p> <p>world</p> </div>
Data Binding 10 struct Main { 11 state: Rc<RefCell<HashMap<String, String>>>
12 } 13 14 impl Component for Main { 15 fn render(&self) -> Node { 16 let key = String::from_str("message"); 17 let message = self.state.borrow().get(&key).unwrap().clone(); 18 v("div", 19 vec![attribute("class", text_value("hoge"))], 20 vec![ 21 v("p", vec![], vec![ 22 Node::Text(message.clone()), 23 ]), 24 v("input", vec![ 25 attribute("value", AttributeValue::Text(message.clone())), 26 attribute("change", AttributeValue::EventHandler(Box::new({ 27 let state = self.state.clone(); 28 move |e: &mut Event| { 29 let key = String::from_str("message"); 30 let mut st = state.borrow_mut(); 31 let node = e.target.as_mut().unwrap(); 32 st.insert(key, node.prop_get_str("value")); 33 } 34 }))), 35 ], vec![]) 36 ] 37 ) 38 } 39 } onchangeͷΠϕϯτϋϯυϥͰstateΛߋ৽ stateͷ༰Λදࣔ
• ྑ͔ͬͨ͜ͱɿܕ͕ݫ֨ • mutabilityɺownershipʹΑ͕ͬͯ Ͳ͜Ͱมߋ͞ΕΔͷ͔ϋϯυϦϯά͕༰қ • ѱ͔ͬͨ͜ͱɿܕ͕ݫ֨ • ΠϕϯτϋϯυϥΛॻ͘ͷʹҰۤ࿑
TODO • ࠩߋ৽ • σʔλϑϩʔ • RustϑϨϯυϦʔͳUtility • ੑೳଌఆ •
…
·ͱΊ • ͍Ζ͍Ζະ • Rustૉఢɺͯ҆͘શͳͣ • Virtual DOMΛ࣮͠Α͏ • ޙʹ͜ΜͳWebϑϩϯτΤϯυ։ൃ͕
ݱ࣮ͷͷʹͳ͍ͬͯΔ͔ʁ
ng-kyoto Angular Meetup #3