# An introduction to WebAssembly
Andrea Peruffo
X: @and_prf
GitHub: #andreaTP
# What is WebAssembly WebAssembly (sometimes abbreviated Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating interactions between such programs and their host environment. [https://en.wikipedia.org/wiki/WebAssembly](https://en.wikipedia.org/wiki/WebAssembly) - Announced: 2015 - Released: 2017
WebAssembly (sometimes abbreviated Wasm) defines
**a portable binary-code format**
and a corresponding text format for executable programs as well as software interfaces for facilitating interactions between such programs and their host environment. [https://en.wikipedia.org/wiki/WebAssembly](https://en.wikipedia.org/wiki/WebAssembly)
# Binary Format ``` 00000000 00 61 73 6d 0b 00 00 00 04 74 79 70 65 87 80 80 |.asm.....type...| 00000010 80 00 01 40 02 01 01 01 01 08 66 75 6e 63 74 69 |...@......functi| 00000020 6f 6e 82 80 80 80 00 01 00 06 6d 65 6d 6f 72 79 |on........memory| 00000030 85 80 80 80 00 80 02 80 02 01 06 65 78 70 6f 72 |...........expor| 00000040 74 86 80 80 80 00 01 00 03 61 64 64 04 63 6f 64 |t........add.cod| 00000050 65 8c 80 80 80 00 01 86 80 80 80 00 00 14 00 14 |e...............| 00000060 01 40 04 6e 61 6d 65 86 80 80 80 00 01 03 61 64 |.@.name.......ad| 00000070 64 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ |d.| ```
WebAssembly (sometimes abbreviated Wasm) defines a portable binary-code format and a corresponding
**text format**
for executable programs as well as software interfaces for facilitating interactions between such programs and their host environment. [https://en.wikipedia.org/wiki/WebAssembly](https://en.wikipedia.org/wiki/WebAssembly)
# Text Format ``` (module (type $0 (func (param i32 i32) (result i32))) (export "add" $add) (func $add (type $0) (param $var$0 i32) (param $var$1 i32) (result i32) (i32.add (get_local $var$0) (get_local $var$1) ) ) ) ```
WebAssembly (sometimes abbreviated Wasm) defines a portable binary-code format and a corresponding text format for
**executable programs**
as well as software interfaces for facilitating interactions between such programs and their host environment. [https://en.wikipedia.org/wiki/WebAssembly](https://en.wikipedia.org/wiki/WebAssembly)
# Executable programs ``` execute add 1 2 > 3 ```
# What is WebAssembly WebAssembly (sometimes abbreviated Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for
**facilitating interactions**
between such programs and their host environment. [https://en.wikipedia.org/wiki/WebAssembly](https://en.wikipedia.org/wiki/WebAssembly)
# Facilitating interactions
WebAssembly is a new fundamental abstraction boundary. https://wingolog.org/archives/2024/01/08/missing-the-point-of-webassembly
# The two sides of it
- compile to Wasm - execute Wasm code
# The problems it solves - sandboxed execution - memory control - speed - standard (W3C)
# Where is it used? - Web Browsers - FaaS - Extensions
# Demo
# Where to find me?
# Apicurio
https://github.com/apicurio API tooling
# Fabric8 Kubernetes Client
https://github.com/fabric8io/kubernetes-client - Java to Kubernetes Resources - Kubernetes resources to Java
# Kiota
https://github.com/microsoft/kiota OpenAPI client SDK generation
# Chicory
https://github.com/dylibso/chicory Wasm runtime in pure Java
# Why The JVM: 30 Years of Value Creation
Enterprise
Cloud
Mobile
Tools and Services
Manufacturers
Banks and Finance
Healthcare
Insurance
Note: - Second, and most important to this project, Is the mountain of value that has been created by the JVM. - Stop for a second and reflect on how deeply the JVM is emebedded into the modern economy. - There's 30 years of JVM software in the world creating hundreds of billions of dollars in value across nearly all business verticals. (conservative estimate) - Think about all the massive public companies that are built on the JVM. - Think about the ecosystems as well, like Android that, power billions of devices across the world.
# Staying within the JVM Boundaries - Guaranteed Memory Safety - Fault Isolation - Super advanced JIT - Self contained programs - WORA: (Write once run anywhere) Platform independent bytecode - ... more!
# Compilers as transformations
# nonorthodox compilers - Linters - Code Generators - ETL pipelines - UI - ...
# Compilers in a developer journey - shared mental/execution model - structured - collaboration
# Thanks and Q&A
https://github.com/andreaTP/uni-wasm-deck
# Extra and optional slides
# Chicory Use cases Note:
## +
## An Unexpected Journey Note:
## An Unexpected Journey - Prism: C Parser for Ruby - JRuby: Ruby on the JVM - Bootstrap: FFI to cross compiled C libs Note:
[Keycloak](https://github.com/pedroigor/keycloak-wasm-policy-provider) policy provider Note: Keycloak is a popular Identity Management software, allowing features like Single Sign On to be easily implemented within corporate services. It's widely used in the Enterprise and it has a wide range of functionalities, for example it allows you to authenticate your accounts with a variety of services, even the old one like Kerberos. Sometimes, the configuration is not enough and you need to write a little plugin to fully customize the behavior of the authentication logic. In this example we integrated a Keycloak Policy Provider able to load and execute wasm functions to verify the user authentication, the wasm module have access to the user context using Host Functions.
# More use-cases - [Apache Camel](https://camel.apache.org/components/4.4.x/wasm-component.html) producer - [Kafka Connect](https://lburgazzoli.github.io/posts/2024-02-01_apache_kafka_connect_meets_wasm_part_1/) transformation - [Apache Pulsar](https://lburgazzoli.github.io/posts/2023-06-13-apache-camel-pulsar-function-pt_1/) function - [Kroxylicious](https://github.com/andreaTP/kroxylicious-wasm) filter Note: By using extension mechanisms we are scaling the complexity of the applications.