4 ms·
Good response. This usage in Rust procedural macros boils down to providing flexibility while improving speed and security. One thing I'd add is that WASM has
by elcritch 7y ago
Good response. This usage in Rust procedural macros boils down to providing flexibility while improving speed and security.
One thing I'd add is that WASM has a few unique advantages compared to other options, which in this case would be shipping a Rust interpreter or using another VM like JVM. Building a Rust interpreter would be a lot of effort to build and maintain, while WASM already has tool-chain support due to it's adoption in browsers. Something like JVM bytecode works differently enough that it's not a standard "ISA" style target in LLVM or GCC tool-chains. WASM is also significantly lighter than many other language specific VM's, provides a decent default sandbox, and is performant enough.
Another potential usage which would be interesting is using WASM in interpreted languages to provide more performant modules/plugins while providing better security/ease of use. Elixir, Ruby, and Python all use native (C) modules for performance, but often are difficult to compile. Being able to precompile modules to WASM would provide better memory safety and be easier to use.