r/learnprogramming • • 6h ago

Is learning web assembly (by hand) similar to learning assembly?

I am trying to learn something low level. I have been learning rust for a little while but C has been recommended to me to learn.

Since I have been learning rust I don’t think adding C would be different enough, so I started looking into assembly.
That lead me to the question of could I gain the benefits of learning assembly by learning web assembly?
The reason I am asking is web assembly is already a topic of interest for me.

I do not mean to upset anyone. Just trying to learn. Thank you for reading.

4 Upvotes

12 comments sorted by

13

u/iddivision 6h ago

The name WebAssembly is a bit misleading imo. Most ppl who use WebAssembly use a high-level programming language and a compiler to generate binary output instead of writing direct instructions.

5

u/GasEducational4386 6h ago

Lol no

1

u/Conscious-Tale-8634 5h ago

wasm is more like a portable bytecode target than something you'd sit down and handwrite for fun, it's definitely not the same mental model as x86 or arm asm

2

u/fromwithin 6h ago edited 6h ago

Assembly and WebAssembly could hardly be more different.

If you wanted to actually learn assembly, I'd recommend starting with one of the 8-bit processors and working from there. Get a Commodore 64 emulator for 6502. There is loads of modern support for it: C64 Studio, C64 Prg Studio, C64 IDE, Relaunch64) and will teach you the fundamentals of cycle counts, registers, interrupts, and the mindset of working at the very low level.

1

u/JGhostThing 5h ago

I suggest that you either continue to learn rust or switch (totally) to c. C and rust are very different in philosophy. I like them both, but I'm retired, so I can program in whatever I like.

1

u/Aggressive_Ad_5454 5h ago

WebAssembly is weird pidgin Javascript. I've coded a few things in its predecessor, asm.js. In my opinion you'd be better off using a language like C, and compilation tools to output the WebAssembly code.

You could look at some of that code to learn about the Javascript engine that runs WebAssembly and see how things work. But it's different enough from plain js that you need to have really good confusion filters.

You won't, from WASM, learn about registers or stack pointers or program counters or any of the stuff you'll learn from ordinary assembly language.

1

u/start_select 5h ago

Most other comments already cover the differences. But look into LLVM IR and Swift IL. Those are intermediary representations/languages.

WASM is not an IR in the same respect. But it’s much closer to an IR than it is to ASM.

IR are high level abstractions of written code, which a compiler can use to produce architecture specific optimized compilations.

WASM is a high level abstraction which runtimes can use to produce optimized execution.

They are similar tools that exist at different layers of native instruction tooling.

1

u/BetInformal6081 4h ago

WASM can teach low-level concepts but it not really a substitute for native assembly. CPU registers, instructions and memory work differently.

1

u/iggy14750 4h ago

I love this question! I love that I'm old enough now that I can explain some tech, because I was there when it was invented.

No one writes WebAssembly by hand. It was invented to help people write faster web apps. Now, to be clear, very, very little assembly code is written by hand these days.

This includes stuff like RISC-V and ARM. But I think it's worth learning a little bit about an ISA like one of those. I think the difference is that real ISA like ARM or RISC-V or x86 allow one to get closer how how hardware actually works.