News for hackers. Stuff that matters.
Re:Libaco: A fast and lightweight C asymmetric coroutine lib... by sametmax on Saturday July 14, 2018 @05:43AM (#17529607)
With coroutines you know when your task switches. You have clear explicit points in your program for that. That makes resources sharing and error handling way easier and predictible.

In threads, anything goes. Anywhere. That's basically goto, but worse because you can't know when the goto happens or where.

Even nurseries, which work great to scope coroutine execution, are nowhere as straightforward with threads.

Re:Libaco: A fast and lightweight C asymmetric coroutine lib... by ur-whale on Saturday July 14, 2018 @07:06AM (#17529819)
>With coroutines you know when your task switches.

Yes, obviously.

>That makes resources sharing and error handling way easier and predictible.

I am actually not so sure about that. With threads, you code knowing fully that your code can be pre-empted anywhere. It's uniform and simple. With co-routines, you have to think about the additional logic of when to yield, and that's very distracting. As a matter of fact, I tend to create more deadlocking code in a co-routine environment than in a threaded one, because - among other things - I'm permanently tempted to get clever.

Re:Libaco: A fast and lightweight C asymmetric coroutine lib... by blattimwind on Saturday July 14, 2018 @08:21AM (#17530033)
> I am actually not so sure about that. With threads, you code knowing fully that your code can be pre-empted anywhere. It's uniform and simple.

The model of threads is fairly simple, but that does not mean that it is simple to program for. In practice developers don't do very well at reasoning about locking.

Re:Libaco: A fast and lightweight C asymmetric coroutine lib... by ur-whale on Saturday July 14, 2018 @09:21AM (#17530234)
> In practice developers don't do very well at reasoning about locking

Agreed. But my point is I am not convinced they fare any better in a coroutine environment once the codebase gets large enough.

Re:Libaco: A fast and lightweight C asymmetric coroutine lib... by sametmax on Saturday July 14, 2018 @11:01AM (#17530588)
With nurseries the situation is much better.