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

Programming

16946 readers
555 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 [email protected]



founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] onlinepersona 0 points 5 months ago (3 children)

WASM still hasn't convinced enough people to drop JS and write their website in something other than JS/TS. Maybe someday...

CC BY-NC-SA 4.0

[–] [email protected] 6 points 5 months ago (1 children)

Isn't DOM manipulation notoriously tedious with WASM? That seems quite a showstopper for most client-side js I'd say.

[–] onlinepersona 3 points 5 months ago (2 children)

Why use DOM manipulation when you can use WebGL? (half-joking, it's what Qt does)

On a serious note, there are rust frameworks (Yew and Leptos for example) that generate all the DOM manipulation stuff for you. No need to touch JS or the DOM in JS.

CC BY-NC-SA 4.0

[–] [email protected] 3 points 5 months ago

I imagine part of the challenge going forward would be the hordes of programmers brought up on designing UIs using a DOM, and all the associated tooling.

My prediction is the situation could be similar to how today many text-only programs assumes a terminal-like device. Terminals have been obsolete for years but I personally feel it's a ball-and-chain on text UI development. The web document model could persist long after web browsers are a kind of "terminal" to load and render web documents.

[–] [email protected] 2 points 5 months ago* (last edited 5 months ago) (1 children)

Got it, but if you expect people to switch from JS to Rust , you're going to be disappointed. That's like asking people who just got their driving license to hop into a fighter jet just because it's faster. JS is a simple language. Its widespread adoption is not due only to it being ubiquitous, but also because it's pretty easy to learn. Rust, on the contrary, not so much.

[–] onlinepersona 1 points 5 months ago

Rust is only one of the languages. There are other languages which compile to WASM: Kotlin, Swift, Zig, Go, C#, and more.

CC BY-NC-SA 4.0

[–] [email protected] 2 points 5 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 3 points 5 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

[–] [email protected] 3 points 5 months ago (1 children)

I had to look up what IINM means. For anyone wondering, it means "If I'm Not Wrong".

Not sure this is worthy of an acronym, but that's your choice! I just wanted to contribute context for people like me.

[–] onlinepersona 1 points 5 months ago (1 children)

Thanks

I thought it was pretty common 🤔 Like LGTM (looks good to me) and IIRC (if I recall correctly).

CC BY-NC-SA 4.0

[–] [email protected] 2 points 5 months ago

It's the first time I see it, but that doesn't mean it's uncommon! 🙂

[–] [email protected] 1 points 5 months ago (1 children)

Honestly I'm better off this way, personally. At least javascript is text, and very often readable after pretty printing and debuggabke as a user, I'm not comfortable with loading basically opaque binaries for websites.

[–] [email protected] 3 points 5 months ago (1 children)

Isn't production JavaScript usually minified/obfuscated to make it hard to read?

Also wasm is actually bytecode, which I believe has a 1:1 conversion into a text-based format called wat.

I agree with your main point though, it's kinda creepy when you realise just how much we are expected to allow other people's code to run on our machines.

[–] [email protected] 1 points 5 months ago

Isn't production JavaScript usually minified/obfuscated to make it hard to read?

Somewhat, but often it's still readable. Or maybe I just don't look at it often enough to notice the worse cases..

Also wasm is actually bytecode, which I believe has a 1:1 conversion into a text-based format called wat.

That's good to be aware of, thanks!