Coding raw WebAssembly Text - Dive into Wat

preview_player
Показать описание

0:00 - Intro & Demos from Ben
1:06 - Hello in Wat
1:49 - Mini Wasm runner
2:36 - Fibonacci numbers in Zig
3:30 - Fibonacci numbers in Wat & Wasi
3:49 - Wasi
4:33 - Main loop, signedness
4:57 - Manual stack
5:28 - Calculating Fibonacci using Wasm stack
6:05 - Program run, more operand stack, binary size
7:04 - Print text and numbers using manual stack
8:04 - String constants
8:18 - Binary Wasm bytes
8:41 - Roland demo & Outro
Рекомендации по теме
Комментарии
Автор

Thanks for the shout out!

WebAssembly is a funny format because it looks like a stack machine, but doesn’t have traditional dup/swap/rot operators, and the text format uses s-expressions but otherwise is not at all like a lisp!

In response to some other comments, WebAssembly is higher level than other machine code formats, primarily in the use of local variables instead of registers, and the requirement to use structured control-flow such as if and loop instead of jumps and branches. Neither of these are needed for safety, however, so it would have been possible to define it a different way.

By the way, there is a “folded” format for the if instruction. It is written like (if (condition) (then (expr)) (else (expr))).

Great video as always!

bensmith
Автор

Having read the wasm spec, this video is very nice because the spec isn't very hands-on to put it lightly. Thank you very much!

tuffenduffen
Автор

Lol, didn't knew wasm text representation is lisp. That's kinda curious

gamerzero
Автор

Very nice showcase. Makes me seriously consider Wat as the target for my toy language. It seems legible enough to do easy debugging on it. It can also compile to standalone executables, which is always desirable.

shilangyu
Автор

Your attention to detail and dedication to your craft is truly inspiring. Thank you for sharing your expertise with us!🖤❣

MyCodingDiary
Автор

This was nice to see. I had a tiny bit of a play with WAT a year or so ago to see if it would bring back the nostalgia of doing machine code on the Z80 and assembly on the 68000.

I didn't play with AssemblyScript though, are you thinking of having a look at that?

andrewdunbar
Автор

2:40 — I take it you're using 0.10.1 Zig? Current way to iterate through integers is for(0..10) |n| {}

Rage
Автор

one thing that bugged me about WAT was that the rules for parentheses arent strict like lisp and it made writing it feel weirdly inconsistent

enirya
Автор

Please help me : This browser does not support WebAssembly.
This problem has occurred in some clients with Windows 11 and google chrome, whose browser is updated.

alirezakarimi
Автор

So, it is much higher-level than machine assembly languages, with strong inspiration from Lisp.

stevenhe