3 ms·
Wow, silly me I misread that thanks for the correction sorry gp. Yes, it has coroutines in the sense that you can queue functions to be run as soon as the event
by nurettin 6y ago
Wow, silly me I misread that thanks for the correction sorry gp. Yes, it has coroutines in the sense that you can queue functions to be run as soon as the event queue is drained, so that it looks like your UI is responsive, but they probably won't be able to run concurrently unless said event loop runs on a separate thread which I don't think it does correct me if I'm wrong.
- FpUser 6y agoCoroutines 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.
- srean 6y ago> 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.