WebAssembly (Wasm) is a programming language that runs on
browsers (stack based VM). Compared to
JavaScript, Wasm is faster, more memory efficient and file size efficient and safer.
Compiling c source
A
C source file can be compiled into Wasm with
emscripten:
The folllowing command produces a
.wast
file.
$ emcc -O3 -g source.c
It is also possible to create a
html file:
$ emcc -O3 source.c -o webPage.html
$ python3 -m http.server 8888
$ open localhost:8888/webPage.html
Misc
When executing WebAssembly, a browser will enforce the same-origin and permissions policies (as it does when executing other code).
WAT
WAT (WebAssembly Text) is a pseudo assembly language for the WebAssembly virtual machine.
WAT has two primary coding styles:
- Linear instruction list style (instructions operating on a stack (push/pop))
- S-Expressions
WASI
WASI is the WebAssembly System Interface.