Advanced¶
For you if you ship Swift and want depth. This level covers the parts of the language that separate "it works" from "it's fast, safe, and well designed": protocol-oriented design and its performance trade-offs, advanced generics, metaprogramming, Swift's concurrency model and data-race safety, ownership, profiling, C interop, and distribution.
Lessons¶
| # | Lesson | You'll learn |
|---|---|---|
| 1 | Protocol-oriented design | some vs any, existentials, dispatch, type erasure, dependency injection |
| 2 | Advanced generics | primary associated types, conditional conformance, phantom types, parameter packs |
| 3 | Property wrappers, result builders & key paths | @propertyWrapper, @resultBuilder, \.keyPath, @dynamicMemberLookup |
| 4 | Macros | freestanding & attached macros, SwiftSyntax, testing expansions |
| 5 | Concurrency: async/await | async let, task groups, cancellation, task-locals, the cooperative pool |
| 6 | Actors, Sendable & data-race safety | actors, reentrancy, @MainActor, Sendable, Mutex, Swift 6 mode |
| 7 | AsyncSequence, AsyncStream & continuations | for await, building streams, bridging callbacks, back-pressure |
| 8 | Ownership | ~Copyable, borrowing/consuming, Span, exclusivity |
| 9 | Performance & profiling | release builds, benchmarking, CoW, ARC traffic, allocation, data structures |
| 10 | Unsafe Swift & C interoperability | pointers, C targets in SwiftPM, callbacks, C++ interop, sanitizers |
| 11 | Libraries, ABI & distribution | API design, DocC, semver, library evolution, static Linux binaries, CI |
| 12 | Capstone: parallel file indexer | a concurrent, tested, race-free application, end to end |
How to work through it¶
- Treat lessons as reference material you revisit. Several (macros, ownership, C interop) reward a second pass after you've used the feature for real.
- Compile with Swift 6 language mode and strict concurrency while you work through the concurrency lessons.
- Measure before you optimise; the performance lesson is a method, not a checklist.
When you're done¶
Build the indexer capstone to the self-check bar: warning-free under Swift 6, clean under Thread Sanitizer, identical output at any concurrency level, and benchmarked with a measured speedup. Then stop studying and go build something real.