We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
WebAssembly in Production: A Compiler in a Web Page • Brian Carroll • GOTO 2023
Discover the power of WebAssembly in production, exploring its limitations and workarounds, from compilation to runtime optimization, and innovative applications like Web REPL and static sites.
- WebAssembly is a binary format that can be run in a browser, but it has its own limitations, such as only being able to understand numbers.
- WebAssembly can’t modify the HTML page or understand JavaScript objects, but it can be used to create a WebAssembly instance that contains WebAssembly functions.
- To overcome these limitations, you need to use JavaScript to interact with the WebAssembly instance and modify the HTML page.
- To achieve this, you can use JavaScript callbacks to communicate between the JavaScript and WebAssembly worlds.
- WebAssembly can be compiled from source code, but it also has its own optimization tools to minimize the binary size.
- The WebAssembly instance has its own memory, which can be accessed from JavaScript using a pointer and length.
- WebAssembly can be used to create a Web REPL, allowing users to interact with the code as they type it in.
- To create a Web REPL, you need to create a JavaScript application that calls into some WebAssembly, and the execution output needs to be displayed in the browser.
- The WebAssembly instance is responsible for evaluating the code, and the JavaScript application is responsible for receiving the output and displaying it in the browser.
- To optimize the compilation process, you can use just-in-time compilation for JavaScript and use WebAssembly’s optimization tools to minimize the binary size.
- WebAssembly can be used to create a static site, without the need for a backend server.