Swift has many tools for concurrency, including threads, operation queues, dispatch queues, Combine and now first class tools built directly into the language. We start from the beginning to understand what the past tools excelled at and where they faultered in order to see why the new tools are so incredible.
Architecture is a tough problem and there’s no shortage of articles, videos and open source projects attempting to solve the problem once and for all. In this collection we systematically develop an architecture from first principles, with an eye on building something that is composable, modular, testable, and more.
The Composable Architecture can help build large, complex applications in a consistent, modular and testable manner, but it can still be difficult to figure out how to solve certain common problems. This case studies collection will analyze some common, real life problems and show how to approach them in the Composable Architecture.
SwiftUI is Apple’s declarative successor to UIKit and AppKit, and provides a wonderful set of tools for building applications quickly and effectively. It also provides a wonderful opportunity to explore problems around architecture and composition.
Dependencies can wreak havoc on a codebase. They increase compile times, are difficult to test, and put strain on build tools. Did you know that Core Location, Core Motion, Store Kit, and many other frameworks do not work in Xcode previews? Any feature touching these frameworks will not benefit from the awesome feedback cycle that previews afford us. This collection clearly defines dependencies and shows how to take back control in order to unleash some amazing benefits.
Parsing is a surprisingly ubiquitous problem in programming. Every time we construct an integer or a URL from a string, we are technically doing parsing. After demonstrating the many types of parsing that Apple gives us access to, we will take a step back and define the essence of parsing in a single type. That type supports many wonderful types of compositions, and allows us to break large, complex parsing problems into small, understandable units.
Each year Apple holds their Worldwide Developer Conference (WWDC) where the next version of iOS, macOS and watchOS are announced as well as hundreds of new APIs. It can be daunting to follow everything, especially when documentation is sparse, so we like to highlight a few particularly interesting topics and dive deep into their details.
We’ve open sourced a lot of software on Point-Free, and every once in awhile we like to give casual tours of one of our projects. This gives us an opportunity to show of some features and discuss topics that are hard to glean from reading the README or documentation.
The Combine framework puts a powerful, reactive programming library in the hands of every person developing for Apple’s platforms. We cover some of the framework’s most foundational and mysterious aspects from first principles so that you can wield its power without getting lost in the zoo of types and operators.
Protocols are great! We love them, you probably love them, and Apple certainly loves them! However, they aren’t without their drawbacks. There are many times that using protocols can become cumbersome, such as when using associated types, and there are some things that are just impossible to do using protocols. We will explore some alternatives to protocols that allow us to solve some of these problems, and open up whole new worlds of composability that were previously impossible to see.
This trio of operations forms the basis of our functional programming toolkit. Each one provides a well-defined, succinct unit of transformation that helps us build up large units from smaller ones. It’s no coincidence that the Swift standard library comes with these operations defined on arrays, optionals, results and more. They are truly powerful operations that can help you take your code to the next level!
There is a wonderful correspondence between Swift’s type system and algebra that we are all familiar with from grade school. By understanding this correspondence we can understand our data structures at a much higher level, and this allows us to remove invalid states from our types, thus making things we want to be impossible, actually impossible.
Enums are one of Swift’s most notable, powerful features, and as Swift developers we love them and are lucky to have them! By contrasting them with their more familiar counterpart, structs, we can learn interesting things about them, unlocking ergonomics and functionality that the Swift language could learn from.
“Domain-specific languages” allow us to capture more domain-specific problems using the features of another language, like Swift. We’ll explore just what that means, starting with a toy example to pave the way for building more real-world examples.
Randomness can seem like a concept at odds with functional programming. By its very nature it is unpredictable and difficult to test. Nevertheless it quickly proves itself to be an ideal case study of composition. We will distill the idea of randomness into a single core unit (a function!) and define a bunch of operations around it that allow us to build up more and more complex notions of randomness that the Swift standard library couldn’t dream of.