|
|
|
|
|
by explaininjs
710 days ago
|
|
This use case is purposefully hamstringed for demo purposes. Rust or Go won’t change anything here, you still need to pass messages to/from the worker. Same exact mechanism as if you used a webworker, which are already widely available. But to answer your question, yes you can use Rust and Go practically in the browser. It just isn’t all that helpful except in narrow circumstances. |
|
The difference with Rust and Go is they have better synchronization capabilities - where JavaScript largely forces you to clone data between threads.
So while you may still be messaging worker threads in Rust/Go - threads share memory which is fast and you have access to things like atomics and mutexes.
We can use Rust in the browser today with WASM and it's super cool - but without something like WASI, extensive thunking through JavaScript is required, plus there are issues with threading.
I hope that one day we can initialize a wasm module via a script tag with the browser offering a wasi interface
`<script src="module.wasm" type="application/wasi">`
And that browsers allow for threading without the restrictive security headers we have today