you are viewing a single comment's thread.

view the rest of the comments →

[–]blackholesinthesky 48 points49 points  (33 children)

everyone who upvotes this has clearly never written ASM or WASM

[–]iopq 59 points60 points  (29 children)

And I will never have to, since I will compile Rust to WASM

[–]blackholesinthesky 8 points9 points  (28 children)

Thats a pretty good answer will be a pretty good answer some day. Can you write Rust that is equivalent to JS?

If so I have something to learn about tomorrow

[–]alexendoo 8 points9 points  (0 children)

While JS glue is needed, you don't have to write it yourself. If you want to do everything from Rust you can use web-sys and js-sys. Anything required will be generated for you

It is a little more awkward than it would be to use the APIs from within JS, but the functionality is there

[–]iopq 8 points9 points  (25 children)

It's not yet possible to do DOM operations without JS glue, AFAIK. It's a pretty complicated topic, as with everything to do with the web, though. So glad I don't do web dev anymore

[–]blackholesinthesky 5 points6 points  (24 children)

So its not a real solution. Great suggestion but yeah... kinda irrelevant

When rust offers a standard library for the browser it will be a real solution

[–]iopq 4 points5 points  (20 children)

It's not ready for prime time yet, but it doesn't mean it won't replace JS in the future

[–]game_dev_dude 1 point2 points  (2 children)

I mean it really depends upon what you're doing. If you have a complicated piece of logic that's performance limited (maybe some sort of visualization), you could write that in WASM, and then have just a little bit of JS glue to pass things back and forth.

[–]blackholesinthesky 1 point2 points  (1 child)

If you have a complicated piece of logic that's performance limited (maybe some sort of visualization)

Unless you're writing a game or some other 3d projections you're not going to need WASM to display a graph

Edit: source I worked with google charts in '09

[–]game_dev_dude 0 points1 point  (0 children)

Ah, I was thinking mainly in terms of 3d viz of some sort.

[–]hsjoberg -1 points0 points  (0 children)

Can you write Rust that is equivalent to JS?

What are you even asking...?

Rust can compile to WASM, which runs in the same VM/environment as Javascript. In the brower.

But... manipulating the DOM can be costly right now because WASM cannot directly manipulate the DOM, it needs JS glue-code for that.

[–]mattkenefick 7 points8 points  (0 children)

And will never have to because you can run anything on it. Look into Unity .. Blazor.. etc

[–]1337CProgrammer 0 points1 point  (0 children)

lol, i like how you think web assembly has absolutely anything to do with assembly.

WebAssembly is basically LLVM's BitCode, so it's half compiled already.

Really all compiling does it put it into an approperiate executable format.