84

I've been wondering about this for a while and haven't really found a great answer for it. From what I understand, WASM is:

  • Faster than JavaScript

  • Has a smaller file size

  • Can be compiled to from pretty much any programming language

  • Can be used outside of the browser easier thanks to WASI

So why aren't most websites starting to try replacing (most) JS with WASM now that it's supported by every major browser? The most compelling argument I heard is that WASM can't manipulate the DOM and a lot of people don't want to deal with gluing JS code to it, but aside from that, is there something I'm missing?

you are viewing a single comment's thread
view the rest of the comments
[-] Kissaki@feddit.de 17 points 1 year ago

Replacing costs expertise, time, and money. Nobody wants to invest that for (to them) insignificant or even pointless reasons.

If you're using tooling, a framework, a library - each of those makes a switch more risky, costly, or impossible.

JavaScript works with the DOM. Why would you want to implement a separate WASM component that you have to interface with? JavaScript is good enough. Interfacing only brings problems with it.

When you use JS you are doing it right - because there is no other way to interface with the DOM. Anything else is built on top. How would you interface with WASM? Manually? Library? Framework? What programming do you use to compile to WASM with? How do you analyze and debug WASM when it executes in a compiled WASM-binary format?

The use case for WASM is performance, efficiency on CPU-bound operations. If CPU-bound performance is not a concern for you, or JS is good enough, there's little reason to use WASM. Other reasons are even more niche.

[-] AnarchoYeasty@beehaw.org 3 points 1 year ago

The language best suited for wasm is easily rust. And you can still interface with the Dom using frameworks like yew sycamore or leptos.

Debugging is still a little tricky but you can debug wasm in chrome and DWARF allows you to have source maps that map to your rust code. This is s problem the community is working to improve. Until then you have the full power of console log which is how a large portion of developers already debug their applications.

this post was submitted on 07 Aug 2023
84 points (98.8% liked)

Programming

17025 readers
184 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