I was investigating using wasm/wasi to implement a parser that is currently written in javascript, such that I would still be able to use it in the browser but also open up other avenues for it to be used on other platforms.
I got bogged down in the wasi/wasm debate and terminology and different available runtimes (or whatever they should be called) - wasmtime, wasmer, wasmedge, fermyon, bytecode alliance... I probably would have spent more time and figured it out if I didn't want to learn rust right now. Seems rust is the best supported language for wasm as far as I can tell.
Otherwise admittedly I would have used a large token context ChatGPT to convert the library to rust for me, and then also have it compile it to wasm.
WASI has the advantage that many compilers support it directly, e.g. in Zig:
> cat hello.zig
const print = @import("std").debug.print;
pub fn main() void {
print("Hello World!\n", .{});
}
> zig build-exe hello.zig -target wasm32-wasi
> wasmtime hello.wasm
Hello World!
Or if you prefer C: > cat hello.c
#include
int main() {
printf("Hello World!\n");
}
> zig cc hello.c -o hello.wasm -target wasm32-wasi
> wasmtime hello.wasm
Hello World!
(I guess Rust can do the same, or for a purely clang-based solution see: https://github.com/WebAssembly/wasi-sdk)....while for web compatibility, you'll always need some sort of shim solution to talk to the Javascript APIs.