What this book is about, and who it is for
Most Swift tutorials teach you what compiles. This book is about what happens after it compiles — where the value gets copied, which call goes through a vtable, what the compiler had to give up when you reached for a protocol, and why the concurrency checker rejects code that looks perfectly reasonable.
Swift is unusual in how much it hides. A struct assignment might copy a hundred bytes or bump a
reference count. A protocol call might be inlined away or might route through a witness table and a
heap box. None of that is visible in the source. You can write a great deal of Swift without
knowing which is happening — until the day a profile comes back wrong, or a data race appears only
on a customer’s phone, and the abstraction stops being free.
You already write Swift daily. You know optionals, closures and if let. What you want now is the
layer underneath: not more syntax, but the model that explains why the syntax behaves the way it
does.
The chapters build on each other rather than standing alone.
struct is the default.async/await, actors and Sendable — a type system for time.Tip
Every code sample here is meant to be pasted into a playground or a swift REPL and poked at.
Reading about a copy-on-write buffer teaches you less in ten minutes than isKnownUniquelyReferenced
printing false when you expected true.
Everything here targets Swift 6 and its strict concurrency checking. Where a feature arrived
recently — typed throws, parameter packs, sending parameters — the text says so, because a
surprising amount of Swift advice online predates them and quietly recommends workarounds for
problems the language has since solved.