Live data from Hacker News

Comparing Rust and JavaScript

chaotic.netlify.app

61–70 of 97 posts

Re: Comparing Rust and JavaScript

#61

More of a comparison between WebAssembly and JavaScript, really. That the WebAssembly was compiled from Rust is not especially meaningful here.

From the user-experience perspective, it matters that it is Rust. Unless you directly write WASM code, which is rarely (ever) the case.

Rust is a language that compiles to WASM. Sure, there are other options to compile to WASM, but they differ by interface (programming language, library, tooling) and (likely to a lesser degree) - performance.

Re: Comparing Rust and JavaScript

#62
post #20

Earlier quoted context omitted.

The fact that it was written in Rust (or any other non-VM lang) is meaningful because programs written in a Language that needs a VM (All the GC'd languages for example) need the vm to be shipped as well. Thus, making the WASM-program larger and slower.

Go is a GC language, but it doesn’t need a VM. It’s a native, statically linked binary that contains the Go runtime.

And that distinction is completely meaningless. It still has to replicate the runtime, the same way as any other managed language.

Re: Comparing Rust and JavaScript

#63

I feel this is a bit of an 'algorithmic fallacy'. If you have a few algs. you need to run under the hood, preferably with few cross domain calls, that can be expressed mostly using a small bunch of native types and not a lot of maps/string etc. then something low-level like WASM might help. But that doesn't match most real world scenarios very well.

Yeah exactly. Try representing a DOM tree without massive indirection.

Re: Comparing Rust and JavaScript

#64
post #61

More of a comparison between WebAssembly and JavaScript, really. That the WebAssembly was compiled from Rust is not especially meaningful here.

From the user-experience perspective, it matters that it is Rust. Unless you directly write WASM code, which is rarely (ever) the case. Rust is a language that compiles to WASM. Sure, there are other options to compile to WASM, but they differ by interface (programming language, library, tooling) and (likely to a lesser degree) - performance.

Given the title I had expected this to be a comparison between the js and rust in terms of development, not performance. I learned nothing new about rust by visiting this page. All I learned was that compiled WASM is faster than js.

Re: Comparing Rust and JavaScript

#66
Rust is a great solution to the memory safety problem, but is more difficult to use and slower to compile than some other languages. I'm wondering why I would use Rust for WebAssembly, which doesn't have memory safety issues?

Re: Comparing Rust and JavaScript

#67
post #66

Rust is a great solution to the memory safety problem, but is more difficult to use and slower to compile than some other languages. I'm wondering why I would use Rust for WebAssembly, which doesn't have memory safety issues?

Because a crash or a data corruption is not great either?

Re: Comparing Rust and JavaScript

#69
post #60

Earlier quoted context omitted.

Sure, but Rust can have a runtime, and presumably Rust on WASM does. If you don't have a runtime in Rust you only get core. https://doc.rust-lang.org/core/ This has obvious effects (you don't have an allocator so you can't have String) and more subtle effects (your slices don't have a sort() method! However they do have a sort_unstable() method) but while it's probably a reasonable environment for the firmware inside…

IIRC every higher level language has some runtime, even C. Question is, how trivial/substantial is it?

[deleted]

Re: Comparing Rust and JavaScript

#70
post #17

More of a comparison between WebAssembly and JavaScript, really. That the WebAssembly was compiled from Rust is not especially meaningful here.

I wouldn't say the source language is not meaningful. If you wrote an ahead-of-time JavaScript-to-WebAssembly compiler and benchmarked the WASM generated by that, it would probably be a lot slower than the WASM generated by the Rust compiler, no?

Has anyone compiled v8 to WASM so we can finally run JS in the browser? ;)
Post reply on HN