Slide 1

Slide 1 text

Rust + WebAssembly ʹೖ໳ͨ͠࿩ Rustೖ໳ऀͷू͍ #5 @T5uku5hi

Slide 2

Slide 2 text

຀໺ ඒ࡙ @T5uku5hi ɾ৽ଔ2೥໨ͷͻΑͬ͜ΤϯδχΞ ɾະܦݧͰΤϯδχΞͷੈք΁ ɾۀ຿Ͱ͸JavaΛ࢖༻ ɾRustΛۀ຿Ͱ࢖͍͍ͨʂ ࣗݾ঺հ

Slide 3

Slide 3 text

ΰʔϧ ɹɾWebAssemblyͷ֓ཁ ɹɾwasm-bindgenͷಛ௃΍࢖͍ํ ͜ͷLTΛฉ͍ͨํʑ͕ɺ ΛཧղͰ͖ΔΑ͏ʹͳΔ͜ͱ

Slide 4

Slide 4 text

WebAssemblyͱ͸ ҰݴͰݴ͏ͱ Webϒϥ΢β্Ͱ࣮ߦͰ͖ΔόΠφϦܗࣜ ໨ඪ (Mozilla MDN web docsΑΓ) ɹɾߴ଎Ͱɺߴޮ཰ͰɺϙʔλϒϧͰ͋Δ ɹɾՄಡੑΛ࣋ͪɺσόοάՄೳͰ͋Δ ɹɾ҆શͰ͋Δ ɹɾଞͷWebٕज़ͱͷޙํޓ׵ੑ͕͋Δ

Slide 5

Slide 5 text

WebAssemblyΛ೷͍ͯΈΑ͏ Mozilla੡ͷΦϯϥΠϯIDE WebAssembly Studio

Slide 6

Slide 6 text

wasm-bindgenͱ͸ RustͱJavaScriptͱwasm͕ γʔϜϨεʹ࢖͑ΔެࣜϓϩδΣΫτ ҰݴͰݴ͏ͱ

Slide 7

Slide 7 text

wasm-bindgenͰRust → JS ɾެࣜνϡʔτϦΞϧΛ΍ͬͯΈͨ ɹίϯ΢ΣΠͷϥΠϑήʔϜ ɹhttps://github.com/rustwasm/wasm_game_of_life ɾRustͷߏ଄ମΛconsole.logͰݺͼग़ͯ͠Έͨ ͠ΐ΅͍ͯ͘͢·ͤΜ

Slide 8

Slide 8 text

ϓϩδΣΫτͷ࡞Γํɾ૸Βͤํ DBSHPHFOFSBUFHJUIUUQTHJUIVCDPNSVTUXBTNXBTN QBDLUFNQMBUFHJU XBTNQBDLJOJU OQNJOJUXBTNBQQXXX OQNMJOL!QLHͷσΟϨΫτϦ OQNMJOLϧʔτσΟϨΫτϦͷ໊લ!XXXͷσΟϨΫτϦ DBSHPJOTUBMMXBTNQBDL DBSHPJOTUBMMDBSHPHFOFSBUF XBTNQBDLJOJUϗʔϜσΟϨΫτϦ OQNJOTUBMM!XXXͷσΟϨΫτϦ OQNSVOTUBSU!XXXͷσΟϨΫτϦ

Slide 9

Slide 9 text

web-sysͱjs-sysΛ࢖ͬͯΈͨ wasm-bindgenͷઈࢍ։ൃதͷcrates✨ wasm-bindgenͰJS → Rust

Slide 10

Slide 10 text

web-sysͱjs-sysͷ࢝Ίํ 1) wasm-bindgenϓϩδΣΫτΛgit clone 2) /example/canvas/src/lib.rsͷத਎Λ ɹॻ͖׵͑Δ 3) sh build.shΛ࣮ߦ DemoΛ͓ݟͤ͠·͢ʂ

Slide 11

Slide 11 text

context.fillStyle͕ະ࣮૷Ͱͨ͠ ৭෇͖ͷϚϦΦʹͳΒͳ͔ͬͨ…

Slide 12

Slide 12 text

ͭ·͍ͮͨ͜ͱ ɾ1.30.0-nightly (28bcffead 2018-09-01) ɾ1.30.0-nightly (0f063aef6 2018-09-03) ͩͱίϯύΠϧʹࣦഊ͠·͢ɻ (issueཱͬͯ·͕͢ະղܾͰ͢) $wasm-pack init΍$sh build.sh͸ɺͦͷཪଆͰnightlyͱ ໊લͷ͍ͭͨ΋ͷΛར༻͍ͯ͠ΔΑ͏Ͱ͢ɻ ɹˠ.rust-toolchainͰόʔδϣϯ؅ཧͯ͠΋ͩΊ

Slide 13

Slide 13 text

ղܾࡦ: खಈͰ໭͢ SVTUVQUPPMDIBJOJOTUBMMOJHIUMZ ./rustup/toolchains ./rustup/update-hashes ʹ͋ΔnightlyΛ࡟আ nightly-2018-08-19Λnightlyʹrename

Slide 14

Slide 14 text

·ͱΊ ɾWebAssemblyͱ͸ ɹWebϒϥ΢β্Ͱ࣮ߦͰ͖ΔόΠφϦܗࣜ ɾwasm-bindgenͱ͸ ɹRustͱJavaScriptͱwasm͕ ɹγʔϜϨεʹ࢖͑ΔެࣜϓϩδΣΫτ

Slide 15

Slide 15 text

͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ