SwiftUI is a Cookie Mould

cookie moulds

New features released at WWDC typically build on, or extend existing components. Things are new, but feel familiar. After spending more time with SwiftUI, I was surprised to find that is not the case. SwiftUI is radical and exciting; like advanced alien technology that takes development in another direction.

Writing code in SwiftUI feels like starting development all over again (almost.) The biggest mind hurdle was realizing @ViewBuilder is a way to create dynamic templates in Swift. Keeping this in mind, the view lifecycle feels like programming static HTML, or a template language like HAML, or Handlebars. SwiftUI creates a static rendering from our view struct, so the lifecycle of our view is very short. There isn’t an opportunity to twiddle with the layout in viewDidLayoutSubviews, and this is a good thing.

ViewBuilder is like a cookie mould, baking up those Views rendered hot from the GPU.