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
Scala to WebAssembly #scala_waiwai
Search
Rikito Taniguchi
February 27, 2024
0
770
Scala to WebAssembly #scala_waiwai
https://scala-tokyo.connpass.com/event/307069/
Rikito Taniguchi
February 27, 2024
Tweet
Share
More Decks by Rikito Taniguchi
See All by Rikito Taniguchi
Scala Days Madrid 2023 参加レポート
tanishiking
0
33
Tooling for Scala3
tanishiking
0
320
API-Based Code Search
tanishiking
0
34
Things happening before start coding with Metals ~behind the curtain of daily coding~
tanishiking
0
520
How we replaced a 10-year-old Perl product using Scala
tanishiking
14
32k
Quick introduction to scalafix
tanishiking
1
140
Format things with scalafmt
tanishiking
1
1.7k
トランザクション技術入門
tanishiking
0
120
Scala製インタプリタをブラウザで動かす3分クッキング
tanishiking
1
180
Featured
See All Featured
BBQ
matthewcrist
80
8.8k
Art, The Web, and Tiny UX
lynnandtonic
290
19k
The Art of Programming - Codeland 2020
erikaheidi
43
12k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
358
22k
The Straight Up "How To Draw Better" Workshop
denniskardys
228
130k
Building Applications with DynamoDB
mza
88
5.6k
Building Adaptive Systems
keathley
32
1.9k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
18
1.6k
GraphQLとの向き合い方2022年版
quramy
33
12k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
Rebuilding a faster, lazier Slack
samanthasiow
74
8.2k
Code Reviewing Like a Champion
maltzj
515
39k
Transcript
Scala to WebAssembly: How and Why Scala わいわい勉強会 #2 tanishiking
What is WebAssembly (Wasm)? - ブラウザで実行可能な、高速・安全・ポータブルで、 サイズとロードが高効率なプログラム形式 - 最近は WASI
(WebAssembly System Interface) によりブラウ ザ外でも活躍 - 様々な言語から Wasm へコンパイル可能 - C/C++, Rust, Go, Kotlin, Dart, Swift, OCaml, Haskell, etc…
Scala -> Wasm へコンパイラバックエンド開発中 https://github.com/scala-js/scala-js/issues/4928
Why Wasm is important for Scala? ブラウザでScalaを実行するだけなら Scala.js があるじゃん? •
高効率なロードと実行・安全性 • (将来的に) ブラウザ外での活用 ◦ Cloud computing (Spin, kruslet) ◦ Edge computing (Cloudflare Workers, fastly edge) ◦ Plugin systems (Istio plugin, shopify function) ◦ Smart Contract (Ethereum Wasm, Near Protocol) • Wasm Component で他言語との interop
https://www.youtube.com/watch?v=QsOHofFJpig 実はかなり前から検討はされていた (2019/06)
Lack of Garbage Collection JVMと違ってWasm(Engine)にGCはない(なかった) GC言語をWasmにポートするには • VM自体をWasmに変換してその上でプログラムを実行 ◦ Ruby,
Python, JS (QuickJS), Java (CheerPJ) ◦ VMを含んでいるので Wasm module が巨大 • GCコードをWasm moduleに組み込む ◦ Swift, Java(TeaVM), AssemblyScript, Go(?) ◦ (実装によるが)非効率・is GC portable?・ホスト環境(JSなど)を介した参 照をトラックできない
WasmGC WebAssembly に GC managed なデータ構造を導入する proposal。Wasm EngineがGC管理してくれる V8, SpiderMonkey,
JavaScriptCore(未リリース?) などで実。 wasmtime などの pure WASI runtime も実装中 Kotlin, Dart OCaml, Java(j2cl)
Demo (時間あれば)
将来の展望 • まずはブラウザで動くWasmに変換を目指す ◦ Scala.js の標準ライブラリは JS 資産利用のまま • (pure)
WASI サポート ◦ そもそも pure Wasm runtime がまだ WasmGC 未対応 ◦ Scala の標準ライブラリもWASIスタックの上で再実装 ◦ 各種 third party library も WASI 向けに再実装する必要がある... ▪ 直接 WASI利用しなければそれほど難しくないはず...(?)
参考 • A new way to bring garbage collected programming
languages efficiently to WebAssembly • Scala.js and WebAssembly, a tale of the dangers of the sea - Sébastien Doeraene • n月刊ラムダノート Vol.4