this post was submitted on 01 Apr 2024
81 points (92.6% liked)

Programming

17406 readers
111 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] SuperSpruce@lemmy.zip 2 points 7 months ago (1 children)

I still have no idea what WASM really is. I've tried looking at articles but it still confuses me. I know how to use HTML, CSS, JS, and actual ARM assembly language at a basic level, but I don't see how any of this could be used with WASM.

[–] onlinepersona@programming.dev 3 points 7 months ago (1 children)

WASM is just like assembly. It has instructions similar to MOV, JMP, STA, etc. It can be distributed as the textual instructions or as the compiled binary format.

When it started it was interpreted by JS or could be compiled to JS directly. It proved to be faster than hand-written JS. However, it still had to go through a JS interpreter. Now, there's a WASM interpreter / virtual machine built into browsers. It's very much the new java bytecode but without running an unsandboxed, external (outside of the browser) java virtual machine.
Given it's an intepreter / virtual machine, it of course has limited APIs in the browser. For a while, it was not possible to access the DOM from WASM, so JS would do the DOM stuff and WASM was called (just like calling an external function in a lib in C/C++/Rust/...) upon to do computationally complex stuff since it was faster than running it in JS through the JS interpreter. IINM, WASM now does have access to the DOM.

Of course there are WASM interpreters outside of browsers that can be included as libraries in other languages. Rust devs are using it for example for plugin systems in their software.

CC BY-NC-SA 4.0