Live data from Hacker News

SwiftUI After 7 Years

ykvm.com

151–160 of 343 posts

Re: SwiftUI After 7 Years

#151
Agreed that SwiftUI because bloated and hacky, when it promised simplification and transparency.

But is there a single UI abstraction that succeeded in affordability for newcomers while maintaining performance and solid architecture?

It is high time to solve the write-3-apps for each usecase (iOS, Android, Windows). I use MAUI on some projects but it is still not perfect.

The way forward for Apple is to open source more and more and let the Swift community build a cross-platform solution.

Re: SwiftUI After 7 Years

#152

I'm sure many will disagree, but I have doubts that pure declarative-reactive is the "right" shape for an all-purpose native UI framework. In my experience, Kotlin+Compose shares many of the same warts… its main redeeming quality is that it's better than Android Framework (most of the time), which is low bar to clear. These frameworks have a number of good ideas but they don't necessarily combine in a way that transc…

I agree, the first section "Data Flow" reflects my concern with Compose as well:

> Data flow in SwiftUI is indeed reactive—but sometimes I wish it wasn’t, because it’s reactive in all the wrong ways. It often reacts to changes it should ignore, and it ignores the changes you actually care about. To me, SwiftUI’s reactivity is a black box: It makes achieving predictable behavior almost impossible.

In Compose, seeing rememberXXX(key1, key2) sprinkled all over with keys makes following the code difficult.

Then add some side effects like LifecycleEventEffect(Lifecycle.Event.ON_RESUME) { ... read permissions and render warning if we can't do something ... } and it becomes even more difficult to comprehend. Much of the Android framework APIs are not reactive, and polling on these UI events is still necessary (permission could have changed if the user put the app in the background, and you can't listen to them via Flow etc).

As the author says, these frameworks make the static data dependencies explicit but often at the expense of what is changing and why.

When I see rememberXXX(key1, key2) { } the first thing that comes to mind is, why would key1 and key2 change, and often that is not obvious.

Re: SwiftUI After 7 Years

#153
post #3

The problem with complex systems is that you can be dead long before you realize you're dead. Things can continue to seem "pretty good" for a long time just from the inertia of past good decisions and built-up infrastructure. You see some fraying or cracks but everything looks fundamentally sound, until it isn't. Apple's inability to deploy a new UI framework that's better than the previous one is troubling. This is…

The underlying problem is the programming industry completely resisting learning the lessons of Objective-C because it doesn't like them. It didn't like them when NeXT tried selling it, and it doesn't like it now.

You can't have Cocoa without Obj-C, or at least a langauge and runtime with that philosophy.

Apple software has been on a clear decline for a seriously long time, and it's propped up almost entirely by them pulling off Apple Silicon combined with how Microsoft have somehow been even worse.

Re: SwiftUI After 7 Years

#154

Earlier quoted context omitted.

> There's no way I'd dare to take on a full Apple-platform app project alone on my own And that's really sad, because earlier Mac OS X (and even OPENSTEP to a degree) was an Eldorado for boutique developers, not least due to frameworks like Cocoa and Objective-C (despite all the hate it seems to get). If you knew C, it was not hard to grasp Objective-C (at least it was much easier than say C++ and MFC on the Windows…

That's actually why I jumped from Windows to Mac in the first place! My first Apple purchase was an iPad I got for my aunt, and I loved how streamlined yet powerful it was so I installed a VM on Windows to dabble in iOS development, and fell in love with the sheer consistency of macOS, iOS and their APIs. This was during the era when Microsoft was still figuring out whether to keep the Start Menu and replace the whol…

> Then came Swift and I loved it, but then it took literal years to catch up with everything you could do in Objective-C with the Apple APIs.

I don't get this part. You can literally rewrite Obj-C code verbatim in Swift and it will work. The only missing part is C macros.

Re: SwiftUI After 7 Years

#155
post #42

Earlier quoted context omitted.

I only have to look at the iPhone fucking 17 to know Apple is long gone.

Genuinely curious, what’s wrong with it? I’m no huge apple fan, but I didn’t really think the 17 was more than a regular boring spec upgrade, which seems fine all things considered. (Currently on an iPhone fucking 17)

Apple did not use to be in the business of producing version 17 of something.

Re: SwiftUI After 7 Years

#156

Earlier quoted context omitted.

I think the problem with SwiftUI in a way was (or is) that Cocoa was so good. And, at least IMHO, it didn't need replacing, just improving. But I feel like Apple wanted to appeal to young web devs and tried to offer something more similar to what these are used to.

I never really tried out Cocoa. What did you like about it?

At least for me, it just had/has the right mix of abstraction and simplicity. It just "ticked" in a way that for example MFC didn't.

But I also really liked Objective-C.

Re: SwiftUI After 7 Years

#157

Earlier quoted context omitted.

Not if you actually do MVC, so solved around 50 years ago. 1. The UI tells the model to change. 2. The model does the change and possible related changes. 3. The model notifies the UI that something has changed. 4. The UI updates itself from the model. Alas almost nobody does MVC, despite calling what they do MVC.

MVC is not bad, but it is not a silver bullet. Calling MVC an ultimate solution to UI is oversimplification. Just looking at the steps you listed I can ask: How do you collect all notifications on step 2 to fire them on step 3 such that UI does not re-render itself too much? E.g. updating a title of each item in a list of 100 items should not trigger 100 renders. Or 100 layout calculations (which I think is harder to…

I never claimed MVC is a silver bullet. Just that it solves "... incredibly easy to forget an edge case in your update logic."

> UI does not re-render itself too much?

Glad you asked! In my Blackbird reference architecture (which is an instance of MVC), I use a coalescing queue to capture the updates. The coalescing is two-level: first, simple duplicates are weeded out. Second, if the update queue gets very full, it becomes coarser-grained, and weeds out duplicates based on that coarser grain. This has multiple steps of grain up to "just re-render the whole UI". Worked like magic in Wunderlist. Except it wasn't magic at all and very simple, inspectable and tractable.

> step 4 UI triggers an event that your model happens to listen

That's not allowed in MVC.

> Because you rely on events how do you avoid “event hell”?

I don't "rely" on events and there is no "event hell". Events are only used in the M→V communication part and there are no subsequent triggers, because the only event is "the model has changed", with an optional payload specifying which part of the model. Important: it must not contain the data that changed, this the view has to fetch from the model once it processes the update event.

Since the only event used is "the model changed", the view cannot ever be a source of those events, so no "event hell".

Re: SwiftUI After 7 Years

#158
I would only take this article seriously if you have to support old iOS versions.

NavigationStack has been around since iOS 16, @Observable since iOS 17. and I'm not sure if the author is aware that GeometryReader hasn't been necessary since iOS 18 added onGeometryChange modifiers. Nearly 100% of users are on iOS 16+.

I'm doing some fairly complex work with SwiftUI and I find most components work identically between iPad and macOS. I can work for a week without needing to test on an iPad.

There are problems with SwiftUI for sure: I'm finding macOS performance on an M2 Max is far worse than an iPad M1, especially with animations. Toolbars are very inconsistent between platforms and the compiler timeouts are a real pain (hopefully Swift 6.4 will fix that).

Re: SwiftUI After 7 Years

#159
post #116

Earlier quoted context omitted.

Not if you actually do MVC, so solved around 50 years ago. 1. The UI tells the model to change. 2. The model does the change and possible related changes. 3. The model notifies the UI that something has changed. 4. The UI updates itself from the model. Alas almost nobody does MVC, despite calling what they do MVC.

I see an M and a V in this description, but no C. Is the UI updating itself automatic or manual? Because if it’s manual, that’s precisely the error-prone part that you’re saying this approach somehow solves - you’ve done the “How to Draw an Owl” meme. If it’s automatic, that doesn’t seem especially different from the React/Redux/Elm/SwiftUI approach (as a sibling points out).

Yeah, M-V-C are all roles, not concrete objects. The C mediates between the input devices and the model, but in practice views can and often do fulfill that role as well. Cocoa views, for example, also fulfill the C role.

Different formulations of M-V-C have the C deal with more complex interactions, with sequences of interactive prompts like wizards.

The update is essentially automatic, and yes: MVC already solved the "problem with MVC" React/Redux/Elm/SwiftUI claim to solve. In 1979.

Re: SwiftUI After 7 Years

#160
post #126

Earlier quoted context omitted.

> Could Apple build MacOS X and Cocoa today if they didn't already exist? Apple got rid of all the NeXT people long ago, with Tim Cook stabbing Scott Forstall in the back, so the answer is No.

This type of story about management getting rid of the old guard is so common and typical, it remains one of the most frustrating aspects of this industry. In the “enterprise scene”, this sort of purge strategy is likely linked to a big percentage of money wasted and sometimes total failure. Why do managers keep making this mistake? “Legacy” is only a bad word in IT. :-(

On the other hand, it is not uncommon for the exiled old guard to form new companies, teams, products and realize their vision under new management.

It is not like their knowledge and experience gets literally purged.

Post reply on HN