4 ms·
I don't understand the part about go, does that mean go doesn't require async but gives you the functionality of async? (I never tried go) The problem with asy
by pca006132 4y ago
I don't understand the part about go, does that mean go doesn't require async but gives you the functionality of async? (I never tried go)
The problem with async is that we can separate when to start a task and when to ask for its result. The compiler can just add await everywhere an async function is called, it is trivial, but you don't get the flexibility of async. If everything is treated as async, you will need to await everything (perhaps some syntactic sugar to allow for immediate await)
- shellac 4y ago> If everything is treated as async, you will need to await everything In go you work rather differently. You let tasks go off and do their thing, and provide a channel to communicate. Pulling a response from the channel is the 'await'. A good part of go's magic is that these tasks - goroutines - don't result in large amount of blocked threads. Java will soon have the building blocks of something rather similar to goroutines.
- pca006132 4y agoOK I see, but I think these two approaches address different problems? The approach used by go is more powerful than async but also more verbose. The implementation is also different, async can be implemented with a generator but goroutine can't.