What does HackerNews think of wac?

WebAssembly interpreter in C

Language: C

#28 in C
#61 in JavaScript
As I wrote, I created a bytecode which fits the compiler's code generator the most. This keeps the entire code base small, the bytecode VM simple and compilation fast. This is a self-contained solution, the compiler as well as the execution environment is part of the emulator; therefore it has to be compatible with itself only, which opens up solutions for simplicity and effectiveness.

Using real world RISC-V instructions would have introduced a lot of complexity without any real benefit. It's not that you can run the MEG-4 scripts without the API library and emulation environment anyway, so at the end of the day the actual instruction encoding doesn't matter.

BTW, if I were to use an existing instruction encoding, I probably would have chosen WebAssembly instead, because it is a lot easier to generate and lot easier to process than a real CPU's instruction set. There are many wasm VM libraries with nice licensing and easy to integrate interface and virtually no dependencies like https://github.com/kanaka/wac for example. But again, implementing wasm's poorly engineered container format and one of its incompatible ABI would just add complexity and have no real benefit.

All that being said, one could implement a new bytecode format in MEG-4 easily if they really want to. It already supports multiple instruction sets (Lua being a working PoC).

Depends on what you mean by “using”. It is conceivably possible to compile a webassembly interpreter like wac[1] with cosmopolitan, which would then run on all OSes and bare metal, yes.

[1]: https://github.com/kanaka/wac

The URL for the original project is [1]

It's strange that the readme says it requires 32 bit userspace tools.

Part of me is pretty excited to have an open "write once run everywhere" environment but the other part of me really likes that autoconf/cmake more or less provide that now and I'm worried that things like this will discourage people from making their projects easily buildable by the end user.

Docker already does that, try building freeciv-web yourself without tools like docker, the end result is that it can be very difficult to modify it when you need to.

[1] https://github.com/kanaka/wac

which was forked from https://github.com/kanaka/wac the kanaka project appears to be a generic platform project where as the grassel fork is targeting the esp32.
To confirm, you're looking for an interpreter? Because most "C implementations" of sorts would instead compile to a standalone binary. If you are looking for an interpreter, while [0] appears out of date, [1] could easily be consumed statically in a C lib and is basically as portable as a C impl. Even better, compile it at runtime and then run it [2]. There's of course the canonical OCaml one [3]. But it would not be hard to write one, WASM is fairly trivial.

0 - https://github.com/kanaka/wac 1 - https://github.com/paritytech/wasmi 2 - https://github.com/sunfishcode/wasmtime 3 - https://github.com/WebAssembly/spec/tree/master/interpreter

This is somewhat related, although embedded here means embedding interpreted WASM into a CLI application.

Similar method might be doable on an MCU.

https://fosdem.org/2018/schedule/event/rust_embedding_wasm/

Then there's "WebAssembly interpreter in C":

https://github.com/kanaka/wac

Looks like it might be good enough for implementing WASM "scripting" support in smallish environments.

> So - since a quick research did not turn up anything - is there a WASM to C "transpiler" that generates readable C?

I'm not aware of one, though it would probably be trivial to write. https://github.com/WebAssembly/binaryen has the helping code for things like parsing. Both https://github.com/kanaka/wac and https://github.com/WebAssembly/wasm-jit-prototype interpret WASM. The latter even JITs into LLVM IR.