3 ms·
> "Green threads" have been around for years, but Go seems to be the first language where they really took off. Java used to be based around green threads back
by masklinn 6y ago
> "Green threads" have been around for years, but Go seems to be the first language where they really took off.
Java used to be based around green threads back in the early day. Lua's concurrency is based around coroutines. OCaml's OS threads are hampered by a GIL so concurrency is generally done via lwt or Async. And of course "green threads" are the very base of erlang / elixir. And Haskell has… Sparks, I think? You could argue that they're not as popular as Go but then… ok?
> This may reflect the use case.
It definitely does. Rust used to use green threads and everything way back in the olden days. That was stripped out, because it's inimical to being the low-level language its community wanted it to be.
If you want to use green threads, you must have some sort of runtime to manage them (scheduling and preempting, maintaining the task queues, …), and probably a GC because this makes the lifecycle of your values way harder to predict and square. But the environment where the Rust community of the time wanted to use Rust did not allow for such overhead. So out they went, to be added later as an opt-in.