← Back to context

Comment by mgaunard

5 months ago

Requiring any implementation who wants to read the data to be able to run webassembly means the format is ill-suited to any environment which aims to reduce dependencies or bloat.

Wasm is pretty simple; Don't confuse it with the "web" part of the acronym. And as others point out; wasm is a backup. You can use native binding without going through wasm, which provide better performance,

  • it needs a compiler to convert it to machine code, it also has a non-trivial runtime...

    • Don't know if you need to compile, you might want to but I think interpreting might seem reasonable if size/complexity is a concern.

      Is the runtime really that large? I know with wasm 2.0 with garbage collection and exceptions is a bit of a beast but wasm 1.0? What's needed (I'm speaking from a place of ignorance here, I haven't implemented a WASM runtime)? Some contiguous memory, a stack machine, IEEE float math and some utf-8 operations. I think you can add some reasonable limitations like only a single module and a handful of available imports relevant to the domain.

      I know that feature creep would almost inevitably follow, but if someone cares about minimizing complexity it seems possible.

    • If you view WASM as a worst case fallback, then you could implement a simple interpreter and transcode the file to something that your program has native decoders for. Yes, that might be slow, but at least the data remains usable. At least, that’s my understanding. I don’t have a dog in the hunt.

If you have a native decoder you don't need to run WASM. It's literally in the abstract.

  • But given a file in this format, you cannot know whether your native decoder can read it without running WASM; the file you read may use a feature that was invented after your library was written.

    • As others said: you can. And what's the alternative? Not being able to read the data or never being able to evolve the encoding.

    • Of course you can, you can literally read the version from the file itself.