One use case I've seen is mostly-safe arbitrary code execution as a service.
Because WASM doesn't have a direct method of calling system API functions, you have quite a lot of control over the runtime. Most JS engines are too powerful to just run arbitrary code (especially if they're not run inside a browser) and other tools (LUA etc.) have libraries that usually assume that the program is not executing code from third parties. With many if not most WASM libraries, there is no unmetered networking, there is no I/O, only methods you explicitly write call wrappers for.
For tools like Cloudflare Workers, WASM can be used as a format that executes relatively quickly, relatively safely. Most software won't be in a position where you'd want to push third party blobs of code and execute it in the backend, but for some programs (SaaS + custom report generation?) it can be a nice plugin platform.
There are, of course, alternatives, but since LLVM and GraalVM compile to WASM, there are tons of languages that can generate a compatible blob.
There is something to be said for code reuse, but the speed of the WASM <-> JS bridge to interact with the DOM makes that use case quite difficult to accomplish efficiently.
Because WASM doesn't have a direct method of calling system API functions, you have quite a lot of control over the runtime. Most JS engines are too powerful to just run arbitrary code (especially if they're not run inside a browser) and other tools (LUA etc.) have libraries that usually assume that the program is not executing code from third parties. With many if not most WASM libraries, there is no unmetered networking, there is no I/O, only methods you explicitly write call wrappers for.
For tools like Cloudflare Workers, WASM can be used as a format that executes relatively quickly, relatively safely. Most software won't be in a position where you'd want to push third party blobs of code and execute it in the backend, but for some programs (SaaS + custom report generation?) it can be a nice plugin platform.
There are, of course, alternatives, but since LLVM and GraalVM compile to WASM, there are tons of languages that can generate a compatible blob.
There is something to be said for code reuse, but the speed of the WASM <-> JS bridge to interact with the DOM makes that use case quite difficult to accomplish efficiently.