Thoughts on async / await in Swift

This is the latest in a series of major language changes that Apple has introduced, going back to ARC in Objective-C. It feels like this one has been a long time coming, but the implementation is thorough and satisfying.

One thing I appreciate is that they revisit framework APIs to offer up modern versions simultaneous with the new language feature. They did the same for blocks and exceptions when they were introduced. One reason they are able to do this is because the APIs are very consistent, and it’s possible to do a mechanical translation.

And even though Objective-C won’t get async/await, the compiler will recognize common asynchronous function signature patterns and offer up async versions in the generated Swift interface.

Another thing that struck me is the deep compiler integration to flag common concurrency bugs. For example, you can’t capture mutable variables by default, so you need to do something to make them safe to use. The common answer will be the new actor concept.

I was somewhat surprised that the various task constructs (async and asyncDetached) and groups were a little more complex that I thought would be coming (I’m not following Swift Evolution very closely). But, the presentations offer good motivation for when you might use them. It also seems like you can start simple and use the more manual mechanisms if you need them.

I’ll see how it goes as I adopt these in Sprint-o-Mat.