3 ms·
"threads" (goroutines) and channels are the new gotos. They tend to make a codebase more difficult to reason about. The more you add, the more you tend to get s
by kstenerud 7y ago
"threads" (goroutines) and channels are the new gotos. They tend to make a codebase more difficult to reason about. The more you add, the more you tend to get spooky action at a distance.
- zerotolerance 7y agoThese are hardly new concepts, nor are there any more appropriate mechanisms for modeling dependencies between multiple concurrent actors. If anything, the traditional shared memory nightmare has proven to be the goto in the room.
- lostcolony 7y agoFunny you should say actors. While some people will equate the two, I find Erlang actors easier to reason about than go channels. Though that has everything to do with monitors and links, to tie dependent goroutines/processes together.
- Thorrez 7y agoUnfortunately Moore's law is no longer expressing itself in terms of single threaded performance. So the only way to take advantage of the faster CPUs that are being released is to write multi-threaded code. Many alternatives to channels (mutexes, atomics, semaphores, condition variables) have just as much if not more chance of turning the codebase into a mess. But yes I agree that if performance-wise you can handle being single-threaded, then do that, because it's much simpler.
- sidlls 7y agoAnd, like the goto statement, surely there will be scolds warning everyone not to use these anywhere instead of treating them like any other language feature to be used with care and as sparingly as possible.