3 ms·
In a Javascript ecosystem, WebAssembly and WASI can play a similar role as native DLLs in Python (or also the role native DLLs are playing in the NPM ecosystem)
by flohofwoe 6y ago
In a Javascript ecosystem, WebAssembly and WASI can play a similar role as native DLLs in Python (or also the role native DLLs are playing in the NPM ecosystem). You can load WASM modules from Javascript code, and those WASM modules can interact with the underlying system via WASI.
This enables some new scenarios:
- You want to use an existing library, but this library isn't available in Javascript. Instead of porting the library source code over to JS, compile it to WASM and call into the WASM module from Javascript.
- You've optimized some piece of JS code, but hit a performance or readability wall (often, JS code optimized for performance is much less readable than "idiomatic" JS). You can port the code to C and compile to WASM instead, this might push the wall a little bit further (not as far away as native code would allow, but often quite close).
The main advantage of WASM+WASI over native DLLs is that they are OS and CPU independent. You don't need a DLL built for each possible OS+CPU combination, instead just compile once to a WASM module.