March 26, 2024

SwiftUI and constraints

I love constraints. Perfect rhymes in songwriting are my favorite example: I could talk for hours about how they improve the understandability of a song, or how they enrich semantics, etc., but by far the most important benefit is that they introduce a design constraint. They restrict my options, reducing thousands of possible line endings to maybe one or two. That’s good.

Jeff Johnson notes that GUI toolkits such as Interface Builder, conceived to boost app developers’ productivity, often fall short. Their primitives are flexible, but this flexibility allows for choices that go against the platform’s idioms.

The opposite is true for SwiftUI. I find its rigidity frustrating, but it discourages non-idiomatic UI patterns. As a result, my designs are usually better.

Now, it’s of course possible to create terrible designs using SwiftUI—just look at the average how-to Medium post. Perhaps we should invite SwiftUI to constrain us even further.