Ruby & WebAssembly Introduction
by
Yuta Saito
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
RubyWorld Conference 2022 Ruby & WebAssembly Introduction Yuta Saito (@kateinoigakukun)
Slide 2
Slide 2 text
About me • Yuta Saito / @kateinoigakukun • ૣҴాେֶ جװཧֶ෦ ใཧֶՊ4 • ύʔτλΠϜ։ൃऀ @ • CRubyͷWebAssembly/WASIϝϯςφ
Slide 3
Slide 3 text
WebAssembly (Wasm) • ϒϥβʹ࣮͞Ε͍ͯΔɺϙʔλϒϧͳ࣮ߦόΠφϦܗࣜ • Google Earth, Figma, GoodNotes, etc.. Introduction
Slide 4
Slide 4 text
WebAssembly (Wasm) • CPUΞʔΩςΫνϟʹґଘ͠ͳ͍ • ιʔεݴޠʹґଘ͠ͳ͍ • ϗετڥͷΞΫηε੍ݶ • ʢͦͦ͜͜ʣߴ https://hacks.mozilla.org/2017/02/creating-and-working-with-webassembly-modules/ ಛ
Slide 5
Slide 5 text
WebAssembly (Wasm) • σβΠϯॳظ͔ΒϒϥβҎ֎ͷڥʹϥϯλΠϜΛຒΊࠐΉ͜ͱΛఆ WebϒϥβҎ֎Ͱศར https://github.com/WebAssembly/design/commit/070f56c5c59030e2d735973f3e10dbe2c87366db
Slide 6
Slide 6 text
WebAssembly (Wasm) • ϒϥβ͔Βಠཱͨ͠WebAssemblyϥϯλΠϜ࣮͕ଟ • Wasmtime, WAMR, Wasmer, etc… • ΞϓϦέʔγϣϯʹΈࠐΈ͍͢ (like mruby) • ϢʔβʹΑΔʮ৴པͰ͖ͳ͍ϓϩάϥϜʯΛೖྗ͢ΔιϑτΣΞͰศར • ྫ) ϓϥάΠϯγεςϜɺαʔόʔϨεɺetc… WebϒϥβҎ֎Ͱศར
Slide 7
Slide 7 text
WebAssembly (Wasm) • ݴޠଆ • WasmʹίϯύΠϧͰ͖Εɺ༷ʑͳڥͰಈ͔ͤΔ • ϓϥοτϑΥʔϜଆ • WasmϥϯλΠϜ͑͋͞Εɺ༷ʑͳݴޠΛαϙʔτ͢Δ͜ͱ͕Ͱ͖Δ ݴޠϓϥοτϑΥʔϜخ͍͠ ϓϩάϥϜަܗࣜʹͽͬͨΓ
Slide 8
Slide 8 text
ϓϩάϥϜͷ୯Ґ Computer Hypervisor OS OS OS OS Libs Libs Libs App App App Computer OS Docker Libs Libs Libs App App App Computer OS WebAssembly Runtime App App App VMΠϝʔδ ίϯςφ .wasm
Slide 9
Slide 9 text
Ruby on WebAssembly • RubyΠϯλϓϦλ (CRuby) ΛWebAssemblyʹίϯύΠϧ • ωΠςΟϒͱ΄΅ಉ͡ػೳΛఏڙ • Ruby͕ϒϥβ/༷ʑͳWasmڥͰಈ͘Α͏ʹʂ • Ͳ͜ͰRuby
Slide 10
Slide 10 text
͜Ε·ͰͷCRubyΛWebAssemblyͰಈ͔͢औΓΈ emrubyʢ͍ʔ͑ΉΔͼʔʣ • EmscriptenπʔϧνΣΠϯͰίϯύΠϧ͞ΕͨCRuby • ϒϥβͰͷར༻͕લఏ Emscripten ϒϥβ֎Ͱಈ͔ͤͳ͍ WASI ඪ४Խ͞Ε͓ͯΓɺ ϒϥβ֎Ͱαϙʔτ͞ΕͯΔ
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
Ruby on WebAssembly puts "Hello, world!"
Slide 13
Slide 13 text
https://kateinoigakukun.github.io/jupyterlite-ruby-kernel
Slide 14
Slide 14 text
https://kateinoigakukun.github.io/jupyterlite-ruby-kernel
Slide 15
Slide 15 text
՝ ίʔυαΠζ • RubyεΫϦϓτͷαΠζ: 22MB • ؆୯ͳMini fi cation -> 18MB • RubyΠϯλϓϦλͷαΠζ: 8.2MB • Asyncifyલ: 5.9MB
Slide 16
Slide 16 text
՝ ىಈ࣌ؒ • RubyεΫϦϓτͷ࣮ߦ·Ͱʹ60ms • ࢀߟɿJSΤϯδϯʢSpiderMonkeyʣ6ms https://bytecodealliance.org/articles/wasmtime-10-performance
Slide 17
Slide 17 text
·ͱΊ • Ruby 3.2ͰWebAssembly/WASIʹରԠ • ʮͲ͜ͰRubyʯͷ1εςοϓ