Scala.js and WebAssembly, a tale of the dangers of the sea
summary
Scala.js IR can be mechanically mapped to WebAssembly (examples: factorial, tail recursion, labeled blocks), and much of the existing toolchain can reuse Scala compiler and SJ IR files — only the final backend must be rewritten to emit wasm. Interop and GC are the blockers: reference types let WebAssembly hold JS objects and Firefox already implements them but GC proposal is early stage, so with reference types code is correct but cannot collect cross-heap cycles and currently none of this fully works yet.
AI-written summary · about
chapters (39)
- 0:00Intro
- 1:32What is WebAssembly
- 2:35Why is WebAssembly a language
- 4:02JavaScript Interop
- 6:25WebAssembly overview
- 8:01Linear memory model
- 8:32JavaScript functions
- 10:28The fun part
- 10:39All of ecology
- 12:09Scala IR
- 13:20Scala WebAssembly
- 15:56Tail recursive factorial
- 17:06Local variables
- 19:38Control flow
- 20:13Linear Memory
- 21:21Virtual Dispatch
- 21:45Interpreter Interoperability
- 24:19Are we stuck
- 26:17Reference types
- 26:29Reference types proposal
- 28:04hello methods
- 28:23decompose
- 30:40lambda
- 31:46any ref
- 32:41call function
- 33:13schematic
- 35:04cycles
- 36:02another proposal
- 36:20new types
- 37:05class points
- 39:41captures
- 40:30when
- 41:44Questions
- 42:02Another path
- 44:20Is it worth the change
- 45:03Performance
- 47:43GBM in WebAssembly
- 49:01Effects in Scala
- 49:49Conclusion
related talks
39mCompiling Scala js to WebAssembly
22mThe state of WebAssembly
35mJavaScript ∩ WebAssembly
17mImplementing and Evaluating a High-Level Language with WasmGC and the Wasm (…)
42mWebAssembly: A New Compilation Target for the Web
32mWebAssembly: birth of a virtual ISA
44mWebAssembly: the browser is now a real virtual machine
42mWebAssembly? Web and Assembler? WTF!
