Scala to WebAssembly
Thank you for coming to my presentation
In this talk, I gonna talk about the new compiler backend that compile Scala to WebAssembly,
WHY it’s important to Scala developers, and how we compile Scala to WebAssembly
hr.icon
Self introduction slide / credits
Before jump into the topic, little bit about me
I'm Rikito Taniguchi,
Scala compiler Engineer working at VirtusLab, where is the company behind Scala compiler and toolings based in Poland
We don't have a booth here, but I and there's a Tomak Gozik who gonna talk about Scala tooling Ecosystem later today, are from VirtusLab, ... TODO
Also, I'm one of the organizer of Japanese Scala community called Scala waiwai land
hr.icon
Agenda
Okay, so let's jump into the topic,
here is the today's agenda
First, I gonnag talk what is WebAssembly
And then Why WebAssembly is important to Scala developers
And How we compile Scala to Webassembly
Finally, I gonna show some demos
hr.icon
What is WebAssembly?
Okay, so ah, if you heard about what is WebAssembly, PLEASE raise your hand
Awesome, almost (maybe?)
Then, if you have made hands dirty with WebAssembly, please raise your hand
Not many, okay
hr.icon
So, WebAssembly is...
WebAssembly is one of the program formats that can be executed in a web browser.
WebAssembly is designed to be fast, secure, portable, and highly efficient in terms of size and load time.
Language-agnostic: C/C++, Rust, Go, Swift, Kotlin, OCaml, Haskell, ... and Scala
Currently, many browsers have a virtual machine embedded that can execute WebAssembly, allowing the development of browser-executable applications using WebAssembly.
hr.icon
Why not Scala.js ?
Okay, it's cool, but you may wonder that, how about Scala.js?
Scala already have a production level JS compiler, and we can develop JS program that runs on browser or Node.js in Scala
In that case, what's the point of WebAssembly for Scala?
hr.icon
There're a lot of benefits over JavaScript!
fast, secure, portable, and highly efficient size and load
(I don't talk the details in this presentation because of time restriction)
Beyond browser
Due to its security and portability, there are also efforts to apply WebAssembly to use cases beyond just browsers.
(In other words, WebAssembly is a technology that goes beyond just being a JavaScript alternative that can run in browsers.)
Evolving Ecosystem
Wasm Component Model
Statck Switching proposal
The security design of WebAssembly encompasses both user security and developer security.
User security refers to protecting the user environment from executing untrusted programs.
Developer security refers to ensuring that a program executes as intended, without unintended behavior being triggered by external inputs.
To readily guarantee both of these security aspects, WebAssembly incorporates several constraints that are not seen in typical CPU or virtual machine instruction sets. Yet, it has been found that WebAssembly can enable the development of a variety of applications that require high expressiveness, even with these constraints in place.
hr.icon
WASI, Component model, WARG
WebAssembly is beyond browser
WASI (WebAssembly System Interface)
WASI enables to provide a way to talk with systems
This allows to run Wasm on non-browser environment, not only JS engine, but also pure Wasm environment such as Wasmtime, wasmedge, and wasmer
For example,
Cloud Server
Edge computing
IoT devices
plugin systems
and so on...
hr.icon
Wasm Component Model
Wasm Component