TOC
Website Home
Download Swift source code in electronic form
Download a copy of the full table of contents.
An Introduction to Programming Using SwiftBrief Table of Contents
0 Preface to the Beta Edition............................................................ lx
I Introduction...................................................................................... 1
1 An Introduction to Programming Using Swift............................ 13
2 An Introduction to Computing..................................................... 63
3 An Introduction to Software Engineering................................. 103
4 Basic Data Types and Statements in Swift............................... 165
5 Decisions..................................................................................... 247
6 Repetition and Loops.................................................................. 335
7 Program Units: Functions and Closures.................................. 389
8 Top-Down Design........................................................................ 513
9 Error Handling............................................................................. 545
10 Sequences, Collections, and Ranges...................................... 579
11 Arrays......................................................................................... 611
12 Sets and Dictionaries................................................................ 687
13 Characters, Character Sets, and Strings................................ 733
14 Enumerations............................................................................ 815
15 Tuples and Structures.............................................................. 903
16 Classes....................................................................................... 991
17 Protocols, Extensions, and Generics.................................... 1157
18 Object-Oriented Programming.............................................. 1317
19 Design Patterns....................................................................... 1391
20 Protocol-Oriented Programming........................................... 1619
21 File I/O...................................................................................... 1683
22 Modular Programming in Swift.............................................. 1753
23 Dates, Times, and Measurements.......................................... 1803
24 Regular Expressions............................................................... 1865
25 Where to go From Here........................................................... 1953
A Glossary.................................................................................... 1967
B Installing Swift on Your System.............................................. 1977
C Answers to the Exercises........................................................ 1985
D Designs...................................................................................... 2015
E Standard Library Mathematical Functions............................. 2157
F Sequence and Collection Methods.......................................... 2163
G Array Reference........................................................................ 2213
H The CPU’s Hardware Stack...................................................... 2261
I Set Reference............................................................................. 2271
J Dictionary Reference................................................................ 2305
K String and CharacterSet Reference........................................ 2335
L Standard Library Protocols (Reference)................................. 2487
M The String Pattern Matching Library...................................... 2505
Index........................................................................................... 2553
All the example source code listings from the book are available in a single .zip file. Source code is in .swift format and ready to compile using Swift under macOS, Windows, or Linux/PiOS.
Purchase Beta Version on GumRoad
An Introduction to Programming, Using Swift
Available in EPUB3, AZW3, and PDF formats.
Special Beta Version Pricing: $5.00 (US)
PDF
EPUB3
AZW3 (Kindle Paperwhite)
Purchase Beta Version on Apple Books (EPUB)
Forum
The all-new introduction to programming in Swift by Randall Hyde!
2,600+ pages long! (PDF version)
Support for An Introduction to Programming Using Swift
Discover how to think like a software engineer while learning one of today’s most elegant modern languages.
In An Introduction to Programming Using Swift, acclaimed author Randall Hyde—known for Write Great Code and The Art of Assembly Language—delivers a complete, hands-on introduction to programming, software engineering, and problem-solving using Swift. Designed for both classroom use and self-study, this comprehensive text combines step-by-step examples, design exercises, and challenging projects to help readers master the language and the discipline of building quality software.
From your first “Hello, World!” to advanced Swift 6.x features, you’ll explore data types, functions, classes, protocols, generics, and design patterns, along with key professional topics such as file I/O, modularization, and regular expressions. Each chapter includes clearly defined learning goals, extensive examples, and “Design It Yourself” and “Program It Yourself” sections that reinforce mastery through practice.
Unlike typical programming books, Hyde’s text integrates real-world software engineering principles—requirements analysis, UML, and iterative design—culminating in Magical Caverns, an interactive game developed in both object-oriented and protocol-oriented styles.
Unlike most Swift books, An Introduction to Programming Using Swift embraces a cross-platform philosophy, teaching Swift on macOS, Windows, Linux, and Raspberry Pi—so you can learn on the system you already own.
Whether you’re a student, instructor, or independent learner, An Introduction to Programming Using Swift offers an engaging path from beginner to professional-level understanding—one that teaches not only how to code, but how to design, reason, and create like a true software engineer.
ABOUT THE AUTHOR
Randall Hyde is the author of The Art of Assembly Language, The Art of 64-Bit Assembly, and The Art of ARM Assembly, some of the most highly recommended resources on assembly, as well as Write Great Code, Volumes 1, 2, and 3, and The Book of I2C (all No Starch Press). He is also the co-author of The Waite Group’s MASM 6.0 Bible.
He has written for Dr. Dobb’s Journal and Byte, as well as professional and academic journals.
Note:PDF version is the recommended reading format as the book formatting matches the original design. Considerable effort was made to ensure EPUB3 and AZW3 formats were as readable as possible, but due to the reflow nature of these formats, some compromises in readability had to be made: PDF (best), EPUB3 with Apple Books (Good), AZW2 on Kindle Paperwhite (acceptable). You may need to adjust font and/or page size on eReaders to produce the most readable output.
Download