Hacker News new | past | comments | ask | show | jobs | submit login

Coroutines do not really run concurrently unless you yield explicitly or call functions that do async io (those yield automatically).

The main reason it is directly available in languages like Go is that they are meant for building servers that do lots of network/file interactions and very little actual calculations. In this pattern coroutine looks rather natural and your code is not riddled with endless explicit yields. As soon as you step out of that pattern coroutines became headache where once must constantly watch and make sure that the interval between yields is not too big and they do not block each other.

In my opinion coroutines are an artificial construct that is very specific to the OS (Windows has fibers for example) and one can argue that it belongs to some standard library rather than first order language construct.

Well Delphi is guilty in this department as well. It has direct language support for automation services on Windows for example.




> In my opinion coroutines are an artificial construct that is very specific to the OS

Coroutines are very convenient outside of OS too. Pipeline of operations, alternative to event loops, agents in a game, ETL all seem (to me) a lot more natural with coroutines than say with OOP. In some languages one has to resort to (preemptive) OS threads for these. Those end up being very heavy weight.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: