Announcing Expert Swift, First Edition!
Looking to take your understanding of Swift to the next level? Dive deep into the inner workings of the language in our newest book: Expert Swift! By Chris Belanger.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Announcing Expert Swift, First Edition!
15 mins
In 2010, Chris Lattner typed mkdir shiny
on his laptop — and that little passion project would ultimately grow into the Swift language as you know it today. Since then, Swift has captured the hearts of millions of developers, and proven itself as a mature, powerful, multi-platform language.
Now, there’s quite a difference between being able to execute print("Hello, world!")
, and being able to leverage the more esoteric features of the language with confidence!
Fortunately, Swift embraces the philosophy of progressive disclosure, which means you’re exposed to only the language complexity you need. You can learn about things like modules, access control, objects, static methods, protocols, generics and escaped characters as they become necessary to what you’re trying to do.
But — how do you get from “Hello, world!”… to using Swift like the experts do?
Beyond the Basics of Swift
As you advance in your career with Swift, you’ll quickly get to a point where you’ll need to know things about the finer details of the Swift standard library, the risks (and benefits) of unsafe
, as well as advanced language features such as higher-order functions, Obj-C interoperability, and even reactive and functional programming concepts — among other things.
Does that sound overwhelming? That’s okay – understanding the language at a deep level isn’t hard. You simply need a friendly guide to walk you through advanced Swift in action, using real-world examples in sample apps that you’d want to use yourself.
That guide is here now, in the form of our latest book: Expert Swift!
Level Up Your Swift Skills
Most of the books you know and love from raywenderlich.com are written in our “by Tutorials” style; however, this book is a little different. Since this is an advanced book, you won’t have a tutorial to accompany each chapter. Instead, you’ll go deep by covering low-level concepts as well as high-level abstractions, by using real-world sample projects to illustrate how the topics in each chapter would appear in real life.
This book is a curated collection of advanced topics that every intermediate to advanced developer can benefit from. Because most chapters in the book cover standalone concepts, Expert Swift is the ultimate reference book to deepen your understanding of specific Swift topics. Read a chapter or two, then take the skills and knowledge you’ve gained back into your existing app development — and reap the rewards.
Trying to explain advanced topics, like the ones this book covers, is not an easy task, so you should expect some longer chapters. Acquiring this advanced knowledge is worth it though, and as you read through the book, you’ll find yourself wanting to jump to your existing apps and implement the techniques you learn.
What’s Inside the Book?
Each chapter of this book presents some theory on the topic at hand, along with Swift code to demonstrate the practical applications of what you’re learning.
The chapters are independent, meaning you can read them in any order you’d like. The only exception to this are the Protocols (chapter 3) and Generics (chapter 4) chapters, which share one sample project.
Some chapters provide a starter project, while in some you’ll use playgrounds to write code from scratch.
This book is split into three main sections, totalling 14 chapters overall:
Section I: Core Concepts
The first section of this book covers the basic building blocks of the Swift language: The type system (enums, structs and classes), Protocols and Generics. You’ll start with a brief refresher of each topic and then jump right into the behind-the-scenes implementations.
The content of this section will expose the inner workings of the type system, as well as get you intimately familiar with protocols and generics:
-
Introduction: Learn the motivations behind creating the Swift language, take a short but deep dive into the Swift toolchain flow, Swift Intermediate Language (SIL), and develop a simple language feature,
ifelse
, to explore some of the facilities Swift offers for creating powerful, expressive abstractions. - Types & Mutation: Types are essential to building Swift programs. The Swift compiler type checks your code to verify correctness, ensure safety and enable greater optimization. You’ll gain experience about the different nominal types and mutation with several small examples. You’ll also implement mutable value semantics for a QuadTree type using copy-on-write dynamic storage.
- Protocols: Get a brief refresher on the basics of protocols as well as some of their more rarely used features. You’ll also learn about common patterns that use protocols as well as some useful gotchas and edge cases to keep in mind.
- Generics: In this chapter, you’ll get intimately familiar with generics by continuing to work on the networking library you started in the previous chapter. You’ll learn how to write generic functions, classes and structs, how to use protocols with associated types, what type erasure is and how to put all that together to make a coherent API.
Section II: Standard Library
This section covers the base layer of writing Swift programs: Numerics, Ranges, Strings, Sequences, Collections, Codable and the less obvious, but very important topic – Unsafe.
As you’d expect from an advanced book, you won’t just see these topics explained; you’ll see each advanced Swift concept in action as you investigate how they’re built, how they’re represented, and how to use them effectively:
- Numerics & Ranges: Through building two apps (BitViewer and Mandlebrot), you’ll see how Swift simplifies programming with protocols and generics. You’ll also look at range types and how operators and generics once again come to the rescue in implementing these language features.
- Sequences, Collections and Algorithms: Sequence, Collection and related protocols form the backbone of the standard library for types like Array, Dictionary and Set. You’ll use these to build several examples including a custom mutable collection to implement Conway’s Game of Life. You’ll also create a chunking algorithm that can be used with any collection type.
- Strings: The proper implementation of a string type in Swift has been a controversial topic for quite some time. The design is a delicate balance between Unicode correctness, encoding agnosticism, ease-of-use and high-performance. You’ll learn how you can most effectively use strings, what they really are, how they work and how they’re represented.
- Codable: When developing your app, you’ll often deal with a myriad of data models and various external pieces of data that you’ll want to represent as data models in your app. In this chapter, you’ll quickly browse through the basics of Codable, and then focus on the advanced materials down the dark corners of codable types.
- Unsafe: In some cases, you might need your code to be extremely optimized, in which case the tiny overhead added by the safety checks from Swift might be too expensive. In this chapter you’ll learn how to use unsafe Swift to directly access memory through a variety of pointer types and how to interact with the memory system directly.