The Shape of Everything
A website mostly about Mac stuff, written by Gus Mueller
» Acorn
» Retrobatch
» Twitter
» Mastodon
» Instagram
» Github
» Maybe Pizza?
» Archives
» Feed
» Micro feed
April 16, 2019

Wasmer is a Python library for executing WebAssembly binaries.

There is a toy program in examples/, written in Rust (or any other language that compiles to WebAssembly):

pub extern fn sum(x: i32, y: i32) -> i32 {
x + y

After compilation to WebAssembly, the examples/simple.wasm binary file is generated.

Then, we can excecute it in Python:

from wasmer import Instance

wasm_bytes = open('simple.wasm', 'rb').read()
instance = Instance(wasm_bytes)
result = instance.exports.sum(5, 37)

print(result) # 42!

I know a lot of devs are ignoring WebAssembly, but I think it's very cool and might be pretty awesome for making desktop like applications run in a browser. I know if I was a desktop only vector illustration tool, I'd really be getting worried about it.

And so much interesting work is being done server side with it- it's like a mini JVM with security in mind. LLVM 8 even has a target for WebAssembly now!