As of now we are all familiar with NodeJS, which is a JavaScript runtime: that means Node.js help us to run JavaScript outside of browser.
Likewise to run WebAssembly outside of browser there are few runtimes such as Wasmer and  Wasmtime which help us to run WebAssembly.
Prerequisites
- An interface to access system resources such as WASI
- A runtime to which we also have support for above interface and C/C++/Rust to wasm compiler
To run WebAssembly outside of the browser we need a way to talk to the system because we want support for features such as sockets, threads, files.
For that we need a system interface and this is where WebAssembly System Interface  WASI Â
comes into play, which is a system interface for the WebAssembly platform.
Wasmer is a WebAssembly runtime having support for system interface  WASI Â
and  C/C++/Rust's to wasm compiler such as Emscripten, Clang, Rust, Clang etc.
Features of Wasmer
- Secure by default. No file, network, or environment access, unless explicitly enabled.
- Supports WASI and Emscripten out of the box.
- Fast. Run WebAssembly at near-native speeds.
- Embeddable in multiple programming languages
- Compliant with latest WebAssembly Proposals (SIMD, Reference Types, Threads, ...)
Installation
To install Wasmer runtime
run the following command
curl https://get.wasmer.io -sSfL | sh
Serving WASM
file
wasmer run test.wasm
Next we will see some examples for non-browser case
Link for browser case can be found here
Latest comments (1)
Thanks for the great write-up, and please don’t get the following noob question personal, I just don’t know where to search for answers.
I’m not very familiar with WASM aspects tbh, but I get really confused when I see and read about things like WASI.
What’s the point of passing the code written in system programming languages like Rust or Go through WASM and transforming it back with WASI to access system resources?
Why not write it to work with bare metal directly from the beginning? What am I missing here?