5 ms·
> I think that stackless coroutines are probably a necessary evil in system languages as full stack switching might have too much overhead. I think it's worth
by jlokier 5y ago
> I think that stackless coroutines are probably a necessary evil in system languages as full stack switching might have too much overhead.
I think it's worth noting that the big operating system kernels - perhaps the ultimate target of "system languages" - tend to use stackful coroutines rather than stackless.
Stack switching tends to be similar speed overhead than stackless, despite surface appearances in how the code may appear. Stackless tends to do more memory allocation and freeing, though.
- gpderetta 5y agoSure, but the perceived advantage of stackless coroutines is not faster switching time, but lower peak memory usage. OSs do not run 100s of thousands of tasks as threads, and when they do they use hand written state machines.