3 ms·
I'd say that they are easier to write code and to reason about when compared with, say, POSIX threads.
by pantulis 6y ago
I'd say that they are easier to write code and to reason about when compared with, say, POSIX threads.
- twic 6y agoHow come? How are goroutines different from real threads such that they're easier to reason about?
- matklad 6y agoIn theory, they are equivalent. In practice, POSIX blocking IO does create problems around cancellation and selectability. For example, there’s no good way to cancel an outstanding blocking read call, and you might need to do weird hops to work around that. If you do goroutines, you need to redo all IO yourself anyway, and that’s a good opportunity to implement things like universal support for cancellation and timeouts.