How do you make a parallel language that transpiles to a reentrant one?

To get more specific for those who may not be as familiar with the nuances of JS: JS can start parallel threads, it just - importantly - cannot share memory between them (instead it must pass messages, copying data at boundaries). This eliminates a large number of benefits and usecases that tend to be associated with "multithreaded programming", but saying JS "isn't multi-threaded" isn't quite true.

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.