Your views on green threads (M:N threading)?

I’ve seen people outside the Haskell space view M:N threading as obsolete or wasteful. I came across this thread, where many people are bashing the concept:

https://www.reddit.com/r/ProgrammingLanguages/comments/6mm4v1/what_are_the_disadvantages_of_an_mn_threading/

Is there any special reason we have M:N in Haskell? Is Haskell unique in this way for some reason?

I see that one commenter raises the subject of real-time systems, and indeed we do not aim to produce code for real-time systems in Haskell.
Moreover:

In short, implementing M:N threading is basically like implementing your own OS in the runtime,

If you need to go beyond what OSes provide to you today, that’s entirely acceptable. After all, we don’t really use the C stack to store the parameters to our functions (it’s a bit of heap).
The Erlang model has shown its disadvantages and (huge) advantages, especially combined with message passing, and individual heaps per actors.

Disclaimer: Personally I’m a great fan of Erlang and hold a lot of affection from my time using it in production. Perhaps I cannot see the fundamental flaws of this model that are poisoning its users. But enlightenment welcome. :slight_smile:

1 Like

One thing that makes Haskell relatively unique is its purity which means concurrent and parallel code is much easier to write, so I think it makes sense that we would want it to have a lower cost than what OS threads provide.

Also note that the thread you link seems to be aimed at individual programming languages amateurs (in the “labour of love” sense). So it makes sense to avoid the complexity that M:N threading brings.