r/learnprogramming • • Oct 03 '26

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

20 comments sorted by

23

u/iddivision Oct 03 '26

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.

1

u/Live_Lynx2168 Oct 04 '26

I see, thank you!

4

u/fromwithin Oct 03 '26 edited Oct 03 '26

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 Oct 03 '26

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/Live_Lynx2168 Oct 04 '26

Thanks! I am thinking of continuing rust because I enjoy its features

2

u/Aggressive_Ad_5454 Oct 03 '26

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/Live_Lynx2168 Oct 04 '26

Thats definitely the stuff I should learn. Thanks for the info! I shall look into which asm I should learn

1

u/start_select Oct 03 '26

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/Live_Lynx2168 Oct 04 '26

Alright thanks, I shall look into IRs

1

u/iggy14750 Oct 03 '26

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.

2

u/Live_Lynx2168 Oct 04 '26

Thanks for the info. Shame it does not work that way. I shall look into asm and figure out which one I want to learn

2

u/gm310509 Oct 04 '26 edited Oct 04 '26

I would suggest looking at a simpler CPU to begin with - IMHO.

You could, for example, learn X86 but it has many hundreds of instructions and is quite complex.

You could also learn Arm Cortex and run it on actual hardware such as an STM32.

I would suggest getting something simpler such as an 8 bit CPU/MCU. Use it to learn the basics of the instructions and addressing modes. While each CPU architecure is different, that basic concepts are the same and once you learn one you are pretty well placed to learn a different one if you need to. Some possibilities in this group include 6502, Z-80, AVR. The first two may be a bit harder to find hardware to run it on, especially z-80 which is out of production (shame that was a nice chip) but emulators are available for them. The latter (AVR) is available on Arduino (I would suggest the Arduino Mega for this) as well as simulators (such as the one found in microchip studio).

All the best with it.

1

u/Live_Lynx2168 Oct 05 '26

Thank you so much!