Dusting Off Coroutines

Coroutines are back! They never really left, but, it looks like different languages are adding native support for coroutines. Coroutines are like cooperative threads, except instead of two cooperative threads, you just jump between blocks of code in one thread. It's good for processing stream data over a network, where you have to block when you're reading data.

The most common experience people have with coroutines are Unix pipes.

It seems many languages are adding coroutines becaise [rogrammers have to deal with more networked data streams, and these streams contain serialized object data. There are multiple streams being merged, split, and routed to multiple outputs. Coroutines help you write code that makes sense. Languages which don't support coding and deployment in this type of environment will be at a disadvantage. (Unfortunately, PHP is one such language.)

Wikipedia article about Coroutines

Coroutines have partial support in Javascript 1.7, which supports a feature called generator-iterator. Mozilla has an article about it.