3 ms·
In go (and anything else with green threads), you pay the price for not putting await in front of stuff by introducing a whole new semantic concept of different
by woah 7y ago
In go (and anything else with green threads), you pay the price for not putting await in front of stuff by introducing a whole new semantic concept of different threads which must now communicate with each other with other specialized data structures etc. Multithreading is useful when you will actually be using the CPU’s full capacity, but is an enormous extra abstraction if not. With async/await you just have to introduce a little extra syntactical clutter.
- amelius 7y agoCan't a compiler easily spot most cases and convert code from multithreaded to async style under the hood, at least in idiomatic Go?
- jules 7y agoYou need synchronisation primitives with async/await too. If you make every function async then you basically have the same as 1:N green threads. If you have pre-emptive threads or true multithreading with a N:M model then you do need to be more careful with synchronisation, but in principle this is orthogonal to async/await vs green threads.