Cheap and dirty
This started as a two-toot-thread on my Mastodon but I couldn't resist the urge to write a few more words. Luckily, I have a blog. This will be about crappy SwiftUI and so this won't be the last post about it.
A few weeks ago I failed a job interview due to my SwiftUI-knowledge. I — still — prefer UIKit and it showed. Not getting the job kind of haunted me, so I decided, as a convinced UIKit connoisseur, to refresh my SwiftUI-knowledge.
In other words: I spent Christmas digging through some tutorials and was reminded why I strongly dislike (and avoided) SwiftUI: Things just don't make sense to me, others feel dirty and not right, so I decided to rant write about it. John Siracusa started #SwiftUWhy for a very similar thing (via mjtsai.com).
SwiftUI feels like an unfinished, but overly complex product built on top of good ol' UIKit. It's a product of hype-driven development, that Apple forced upon us for whatever (read: money saving, I guess?) reason. Born from a tool for prototyping, quickly stitched together, merged into Crossplatform-crap for Apple platforms, basically the React Native-version of Swift. Swift Native. TIHI.
Let's start with something small, something from the SwiftUI-introduction: You build a little landmarks-app with some user input handling.
To get the data into the LandmarkDetail
-view, the tutorial uses @Environment
. But to connect the model data to the view itself (and vice versa), it suggests a @Binding
. You end up with something like this:
struct LandmarkDetail: View {
@Environment(ModelData.self) var modelData
// ...
var body: some View {
// WHY???? ⬇️⬇️
@Bindable var modelData = modelData
// ...
}
}
Remember if let modelData = modelData
from years ago? This feels so unelegant nowadays and so does var modelData = modelData
. Also that modelData
needs to be there twice as @Environment
and @Bindable
. Maybe it makes more sense once I become a SwiftUI connoisseur. Or I get used to that.
I want to build things slowly and thoughtfully, and for that, SwiftUI does not feel like the right tool. It feels more like fast fashion-tool, something to quickly build cheap crap with you can easily throw away. And due to that, you build more, wasting time, money, and resources, as it's so easy, while guessing what's right, instead of thinking and asking: "What is right?".
In times, where we should build less, but more carefully, sustainably and thoughtfully.