4 ms·
I don't know why I didn't come across it. Maybe if I took Operating System II ..
by hasenj 14y ago
I don't know why I didn't come across it. Maybe if I took Operating System II ..
- javert 14y agoI think you would have had to go deeper into programming languages, not deeper into operating systems. Disclaimer: The above is definitely true for coroutines in general, but I don't know much about Go and whether its coroutines are truly unique.
- MaxGabriel 14y agoI also heard of it in a programming languages course, and also in Udacity CS 212 I think. To add to the list, they're implemented in Python using yield statements
- nas 14y agoPython's yield was originally a limited co-routine, something we coined as a "generator" (borrowing the word from Icon, which Tim was quite fond of). It was limited to one frame on the stack and could only return values. Recent enhancements have allowed values to be passed back into the suspended function. That's still not a full co-routine though since Python only lets you go one level down on the stack. As someone else mentioned, you need to get deeper into programming languages, not operating systems. Scheme has call/cc which can be used to build co-routines. Someone needs to clue in the nodejs crazies as well, callbacks are not the way to design a language. ;-)
- mattgreenrocks 14y agoAll of the node.js kids get really defensive when you point this out; as if async was supposed to be heinously ugly despite the fact that the entire raison d'etre of node.js is to be async. Programming advances so slowly because all of the training required to become familiar with it eventually becomes a blind spot.
- swdunlop 14y agoIt is hard to get excited about concurrency in vanilla Python while the Global Interpreter Lock still chokes everything down internally. (Vanilla, here, should be read "not Stackless.") For more effective use of lightweight processes, I'd probably reach for Erlang or Occam.
- masklinn 14y agoNot sure why, the GIL is not an issue to node-style concurrency (based on an event loop and async IO), though you need alternative IO layers (Gevent provides exactly that, and can — if requested — monkeypatch the stdlib to replace standard synchronous IO calls by Gevent-provided async IO). In fact, mixing threads and an event loop with async IO is probably a good way to make everything blow up.
- chubot 14y agoIt's not surprising you didn't come across it -- I never did in school either. From what I can tell, it's because coroutines were an old idea that were eclipsed by OS threads and the like. They basically became interesting again when OS threads reached scalability limits. This paper by the authors of Lua has some good historical background: http://lambda-the-ultimate.org/node/2868 http://lambda-the-ultimate.org/node/2868 They also poke fun at Python in some ways because the coroutines are fairly limited. Python got them sort of ad hoc with yield in Python 2.4 and send() in Python 2.5. I think Python is by far the most popular language with any kind of coroutine. Coroutines aren't very popular or well understood.