What does HackerNews think of threads?

Threads and Atomics in WebAssembly

Language: WebAssembly

That's incorrect. WASM supports the exact same multi-threaded/shared-memory/atomic-operations model as the JVM: https://github.com/WebAssembly/threads
For what it's worth, there's some limited ability to share memory (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...), though you can only share binary data, not other types, and it only works in secure and cross-origin isolated contexts, due to security concerns.

That being said, at first glance it doesn't look like Clio is using this, instead it's passing messages as you suggest. It might actually be interesting to use SharedArrayBuffers as a compilation target, as they're probably hard to use correctly manually. That being said, WebAssembly threads (https://github.com/WebAssembly/threads) may be more appropriate for this.

For completeness, Workers can also transfer memory (https://developer.mozilla.org/en-US/docs/Web/API/Transferabl...) with less security restrictions. They can also collaborate by accessing a shared database (https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_A...) though this is obviously slower than shared memory.

There is of course the threads proposal [1], which works in chrome with a feature flag, but most runtimes don't support it yet.

In general I have to agree that WASM needs more time. There are multiple quite crucial proposals in the pipeline (reference types, interface types, threads, tail calls and other advanced control flow, module linking, (GC), ...) which have all seen very slow progress.

Overall I'm still bullish on the potential of WASM for universal deployment, but the slow pace is a bit concerning.

[1] https://github.com/WebAssembly/threads

Good news! WebAssembly has community group projects setup for both multithreading [0] and multi-memories [1] which would allow a module to both define a memory space and also import a shared one.

There are so many parties interested in wasm, there are a ton of inflight proposals and extensions to get it beyond the mvp stage.

[0]: https://github.com/WebAssembly/threads [1]: https://github.com/WebAssembly/multi-memory

Quick notes... The threads feature is in proposed status vs others that are in implementation status [0], but I assume this has been implemented before things like multi-value. I wonder why threads first, I assume just for experimentation. It should be noted that threads are essentially atomic memory accesses and wait/notify, nothing for starting a worker inside of WASM or anything, that is still in JS land. The test cases don't appear to include wait/wake nor does the test case interpreter that I saw [1]. Also, "Report issues" in the blog post links to https://TBD.

0 - https://github.com/WebAssembly/proposals 1 - https://github.com/WebAssembly/threads

This might not be best way measure wasm performance. WebAssembly can be 2-5x fater than JavaScript.

Not to forget wasm is in very early stage, once we get threading support(https://github.com/WebAssembly/threads) we can get much better results.

No, though neither is Javascript. (I am not sure how far along non-WebWorker-based wasm threads are, but here's the proposal: https://github.com/WebAssembly/threads)