This is a tremendous book. Aimed at developers that already have some experience with Swift, the book’s promise is to help them write better code in their real-world Swift projects. In a handful of words, this means balancing the right techniques and Swift features to craft more robust code (think compile-time safety), code that better expresses intent and is thus more easily maintaned, and why not, code that’s also quite ellegant.
The book is fairly easy to read. Concepts are explored gradually, with a focus on how to reason about the various constructs of Swift. Different approaches to solving a certain problem are presented side by side, with pro’s and con’s presented for all cases.
Theoretical aspects are balanced by an abundance of code examples, more than you’d normally find in a programming book. The author has put a lot of effort into demystifying abstract concepts on the spot into the mundane (but useful) examples you’re likely to encounter in your day to day work as a programmer. There’s little place in this book for highly theoretical constructs, and focus is clearly set on exemplyfing techniques with code samples. Worth noting, these are less like “class Foo” of “func Bar()” geeky examples, and more like snippets you’d see in a real project, such as a Network Layer with monadic error handling, or useful additions you can make to Swift’s built in Sequence/Collection types.
In my case, the list of takeaways after finishing “Swift in Depth” is by no means short:
How to reason about generics and protocols with associated types.
When to favor compile-time generics, and when usage of run-time protocols will save you some embarrassment.
Asynchronous error handling, with a touch of ellegance.
Harvesting the power of enums.
The benefits of conditional conformance.
High-order functions (flatMap, anyone?).
And how to nod politely when colleagues mention rigid class hierarchies in the days of protocol oriented design.
And when it is socially acceptable to use forced unwrapping of optionals …was that in the mornings, right before going to lunch? Oh, nevermind.
There’s bits as well for those more willing to explore the really shady/difficult constructs of Swift. Think type erasure, and others.
There’s also bits of comical relief here and there … I’ll just note down my favourite, which is when the author feeds the “OMG Shoes!” text to an URL initializer.