In my previous articles I talked about how WebAssembly allows you to bring the library ecosystem of C/C++ to the web. One app that makes extensive use of C/C++ libraries is squoosh, our web app that allows you compress images with a variety of codecs that have been compiled from C++ to WebAssembly.
In my experience, most performance problems on the web are caused by forced layout and excessive paint but every now and then an app needs to do a computationally expensive task that takes a lot of time. WebAssembly can help here.
Emscripting a C library to Wasm
Sometimes you want to use a library that is only available as C or C++ code. Traditionally, this is where you give up. Well, not anymore, because now we have Emscripten and WebAssembly (or Wasm)!
Emscripten and npm
WebAssembly (wasm) is often framed as either a performance primitive or a way to run your existing C++ codebase on the web. With squoosh.app we wanted to show that there is at least a third perspective for wasm: making use of the huge ecosystems of other programming languages. With Emscripten you can use C/C++ code, Rust has wasm support built in and the Go team is working on it, too. I'm sure many other languages will follow.
WebAssembly for front-end web development. Emscripten vs Rust vs Blazor.
I was lucky to be involved in an evaluation of WebAssembly for an in-house web frontend project. The project basically involves an Admin Dashboard where a user logs in to monitor what is going on, looks at some sales charts and orders activities. In the evaluation, our goal is to determine whether it is feasible to use WebAssembly for front end web development, and if possible, build a prototype to prove the feasibility.
A better way to write Web Assembly
Signing WebAssembly Modules with Rust
In my book, I wrote an Appendix that included some code samples illustrating how to cryptographically sign WebAssembly modules, but these were more to illustrate some interesting Rust syntax rather than prescribe real-world, production patterns. For example, the signing in that appendix prepended a 64 byte blob to the Wasm binary, making it unusable by any of WebAssembly’s standard tooling (or parseable by regular hosts).
WebAssembly & CloudABI
ABI stands for Application Binary Interface (wiki page).
We can see an ABI as a contract between two binary applications, to assure that one binary is able to access certain native functions from the other binary.
Each time we compile a C or C++ application there is a set of system calls that the application will normally use, for example, to open a file, read its contents… or even opening a socket.
For doing that, the applications normally target the POSIX ABI to run these syscalls in Unix-like systems. There are different implementations following POSIX, such as libc, musl…
Read the article: https://medium.com/wasmer/webassembly-cloudabi-b573047fd0a9
Practice your Go WebAssembly with a Game
Marker Tracking in Babylon.js
Read the article: https://medium.com/@babylonjs/marker-tracking-in-babylon-js-ce99490be1dd
Running WebAssembly 100x faster 🔥
We’ve been working steadily to get Wasmer to execute WebAssembly modules on the server-side as fast as possible.
TL;DR — We got 100x improvement on startup time on Wasmer 0.2.0
Before getting into details, it’s essential to understand how Wasmer works under the hood to see what could be improved.
Read the article: https://medium.com/wasmer/running-webassembly-100x-faster-️-a8237e9a372d