jamiebuilds / ghost-lang

:ghost: A friendly little language for you and me.
302 stars 10 forks source link

Thread syntax sugar #7

Open aleclarson opened 6 years ago

aleclarson commented 6 years ago

It might be cool if there was syntax sugar for "threads" (the definition of which depends on the target platform). For example, threads would compile to web workers for a browser target.

jamiebuilds commented 6 years ago

Ghost has reached a point where it would have to be compiled to Wasm which is starting to have support for threads now https://developers.google.com/web/updates/2018/10/wasm-threads

I'm not sure what's needed for syntax other than potentially a syntax for moving/copying values into closures to be spawned as a thread

SCKelemen commented 6 years ago

This looks a lot like a language I have been working on. Have you consider alternative concurrency models such as Actors or CSP?

jamiebuilds commented 6 years ago

Actors, CSP, etc are things you would implement on top of threads. I think they would be more in the stdlib.

aleclarson commented 6 years ago

Thoughts on cooperative threading vs preemptive threading?

SCKelemen commented 6 years ago

I don't think that needs to be true. CSP, Actors, and threads are all independent concurrency paradigms. All of them can be implemented completely independently and without any other, and each can be implemented on top of any other.