News for hackers. Stuff that matters.
Re:WebAssembly Text Code Samples by segfaultbuserr on Saturday April 22, 2023 @12:09PM (#35667980)
> Back to the original goal of this post. While I enjoy writing WAT code, one aspect of the experience that could be improved is documentation. The WASM spec is much more suitable for formal verification than for actual documentation purposes; specifically, it's hard to grep and doesn't provide much in terms of examples. This is alright for a spec, but I couldn't find complementary resources that just show code samples.

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...

Re:WebAssembly Text Code Samples by syrusakbary on Saturday April 22, 2023 @01:23PM (#35668854)
This is awesome, as it helps Wasm newcomers to overcome the chasm and see what everything is all about with simple examples.

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 :)

Re:WebAssembly Text Code Samples by eliben on Saturday April 22, 2023 @08:37PM (#35672239)
> (although I wished it was a bit more extended!).

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?

Re:WebAssembly Text Code Samples by detrites on Saturday April 22, 2023 @01:44PM (#35669091)
Article is great, but is quite brief. Good resource with fair bit of detail & examples here:

https://developer.mozilla.org/en-US/docs/WebAssembly/Underst...

Re:WebAssembly Text Code Samples by irsagent on Saturday April 22, 2023 @04:10PM (#35670474)
This resource was very helpful as an addendum.
Re:WebAssembly Text Code Samples by JasserInicide on Saturday April 22, 2023 @04:18PM (#35670534)
Been hearing about WASM on here for years now, but it's never about people actually using it. Are there any high-profile cases of it being used?
Re:WebAssembly Text Code Samples by lioeters on Saturday April 22, 2023 @05:22PM (#35671033)
One that comes to mind is the WASM port of FFmpeg:

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:

https://github.com/copy/v86

A fun project is WASM-4, for building retro-style games:

https://wasm4.org/

Possibly more interesting projects to be found here:

https://github.com/topics/wasm

https://github.com/mbasso/awesome-wasm

Re:WebAssembly Text Code Samples by fyrn_ on Saturday April 22, 2023 @05:29PM (#35671085)
Zoom uses it quite extensively, Figma is built in it.
Re:WebAssembly Text Code Samples by loaph on Saturday April 22, 2023 @06:04PM (#35671317)
My understanding is that https://photopea.com (very handy for basic photoshopesque image manipulation) uses it
Re:WebAssembly Text Code Samples by fancy_pantser on Saturday April 22, 2023 @07:33PM (#35671869)
Re:WebAssembly Text Code Samples by nequo on Saturday April 22, 2023 @08:17PM (#35672120)
Google Earth in the browser uses WASM too:

https://blog.chromium.org/2019/06/webassembly-brings-google-...

Re:WebAssembly Text Code Samples by sp332 on Saturday April 22, 2023 @09:12PM (#35672412)
Just to be clear, wasm is usually a compilation target, not someting written by hand like on that site.
Re:WebAssembly Text Code Samples by leephillips on Sunday April 23, 2023 @09:31AM (#35676086)
Fluid dynamics in your browser with a Julia program compiled to WASM:

https://discourse.julialang.org/t/inviscid-and-incompressibl...

Draw fluid boundaries with your mouse!

Re:WebAssembly Text Code Samples by burntcaramel on Saturday April 22, 2023 @07:23PM (#35671815)
This is fantastic. The specs and the MDN documentation are pretty detailed, but I’ve found I need a fair bit of trial and error to understand some WAT language features.

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...

Re:WebAssembly Text Code Samples by Jasper_ on Saturday April 22, 2023 @07:55PM (#35671986)
At one point I hand-wrote a simple Brainfuck interpreter in both WAT (called WAST at the time...) and asm.js. Both are extremely tedious, but it seems WAT has improved a bit ergonomically since...

https://github.com/magcius/bfasm/blob/master/bfasm.js

https://github.com/magcius/bfasm/blob/master/bfwasm.wast