WebAssembly in Production: A Compiler in a Web Page

Added:

Intro to WASM
REPL Benefits
Web REPL Demo
Architecture Shift
REPL Compilation
Core Challenges
Size Reduction
New Entry Point
JS Interop Need
Input Handling

Intro to WASM

0:12
Playing Section
  • 1

    WebAssembly is a binary format enabling non-JavaScript languages in browsers.

  • 2

    Most attendees haven't used WASM in production; this talk covers real-world usage.

  • 3

    Focus is on the open-source 'Rock' language project and its web-based REPL.

Basic understanding of WebAssembly (Wasm) architecture, including its binary format, stack-based execution, and purpose as a compilation target.
Intermediate proficiency in JavaScript, specifically asynchronous execution (Promises, async/await) and the interaction between the JS engine and the browser API.
Fundamental concepts of compiler design, such as parsing source code, generating Abstract Syntax Trees (ASTs), and emitting executable code.
Familiarity with web performance profiling, including memory footprints, thread blocking, and the limitations of JavaScript for CPU-intensive tasks.
Advanced WebAssembly features, including multi-threading, SIMD (Single Instruction, Multiple Data) optimization, and the WasmGC (Garbage Collection) proposal.
The WebAssembly System Interface (WASI) for executing compiled code outside the browser, such as in serverless environments and edge computing.
Low-level memory management in Wasm, focusing on manual linear memory manipulation and secure data marshaling between JS and compiled languages.
Enterprise production strategies for Wasm, such as progressive enhancement, streaming compilation, and module caching mechanisms.
104.9K views2.3Klikes37:14@GOTO-Original Release: 2024-03-29

Deploying a complex compiler like Roc's REPL in WebAssembly requires addressing three main challenges: reducing download size by creating a dedicated entry point and removing unnecessary subsystems (achieving 2MB after compression), handling WebAssembly limitations by using JavaScript for DOM manipulation and async operations while passing data through shared memory, and implementing proper JavaScript/WebAssembly interop for string handling and async callbacks; this approach enables static site deployment without backend servers while maintaining interactive developer tool functionality.