node.jswebassemblywasi

Node WASI vs spawning a child process


In the NodeJS docs it states the following:

The WASI API provides an implementation of the WebAssembly System Interface specification. WASI gives sandboxed WebAssembly applications access to the underlying operating system via a collection of POSIX-like functions.

My question is:

What is the biggest benefit of using the WASI API over, say, spawing some other child process or similar methods of running non-nodejs code?

I would have to assume it's faster than spawning a child process, or using some C code with bindings due to the native-api.

Maybe I'm simply misunderstanding the entire idea behind WASI, which is plausable, given that part of what makes WASM so amazing is the ability to use a server-side, full blown programming language on the web (mostly), like all the crazy tools we've seen with Go/Rust.

Is this more so for the benefit of running WASM in node, natively, and again, if so, what are the benefits compared to running child processes?


Solution

  • I ended up getting my answer from a post here that was removed.

    In really high-level terms, WASI is simply an (systems) interface for WASM.

    I ended up finding this short 'article', if you will, super helpful too!

    Just as WebAssembly is an assembly language for a conceptual machine, WebAssembly needs a system interface for a conceptual operating system, not any single operating system. This way, it can be run across all different OSs.

    This is what WASI is — a system interface for the WebAssembly platform.