WebAssembly Text Code Samples
eli.thegreenplace.net
eli.thegreenplace.net
I know the pain. One time, I was trying to use an experimental academic research tool. The tool accepts an input file, written in a custom language. The language is fully documented, but the only thing the documentation did was listing the syntax of each command in BNF notation. But at least it had demo code in the repo so you could read code and doc side by side to figure out how the code should look like...
https://developer.mozilla.org/en-US/docs/WebAssembly/Underst...
The loop with a block directly inside is a good regular pattern! I’ll be using that all the time now.
I’ve been writing an Elixir DSL for WAT. Elixir has a powerful macro system, so I can closer to that pseudo C-syntax in this post, plus some other niceties. I plan to open source it as a library soon.
Here are examples I’ve written in it, like an HTML escaper, stateful HTML component, bump allocator, and a few state machines.
https://github.com/ComponentsGuide/components_guide/tree/mas...
https://github.com/ffmpegwasm/ffmpeg.wasm
Another is the SQLite WASM project:
https://sqlite.org/wasm/doc/trunk/index.md
Also v86 for x86 machine virtualization in the web browser:
A fun project is WASM-4, for building retro-style games:
Possibly more interesting projects to be found here:
https://blog.chromium.org/2019/06/webassembly-brings-google-...
https://discourse.julialang.org/t/inviscid-and-incompressibl...
Draw fluid boundaries with your mouse!
It's also very true that overall the Wasm docs can use some help. Hopefully we will be able to help with it as part of our work in Wasmer :)
What additional samples would you like to see in there?
> Hopefully we will be able to help with it as part of our work
That's great to hear. What are you planning here?