Why I quit using SwiftUI
chsxf.dev
chsxf.dev
Success to me looks like steering clear of SwiftUI for now, and advocating for Apple to hire documentation editors/leaders who can 1) create SwiftUI documentation of code examples for how to escape out of SwiftUI to handle more-complex cases, and 2) accelerate Xcode speedups of SwiftUI testing-and-instrumentation techniques such as View testing (e.g. ViewInspector) and integration testing vs. unit testing (e.g. reactive vs. dependency injection vs. extension tests vs. protocol tests etc.)
Will it ever be mainstream for iOS/MacOS? Maybe, if Apple would use it way more than they have so far, thus improvement by dogfooding. It is nice to build apps this way, but there are way too many bizarre gotchas still for most people unless you can live with more flexible designs.
For those "stupidly complex UIs", SwiftUI just doesn't have enough hooks for customization. And the improvements are too slow. Using SwiftUI has been bitter-sweet. It feels like you just can't use it to craft a high quality app that doesn't look like a generic iOS app.
Maybe Instagram, Discord... I was going to say Robinhood, but the free trading might have been the real differentiator?
To be honest, as a user, I'd really rather see more "generic iOS apps". I think too many design teams are self-centered and do not consider that users need the apps not to admire their wonderful creations, but to get certain things done. In other words, your app is the center of your world, but it is not the center of mine. It's something I want to use to get stuff done quickly, with minimum effort, and with minimum cognitive load. Generic is good.
It’s not released yet, but my beta testers seem to love it. Most of them are non-technical. I haven’t written the on boarding stuff yet but the generic UI/UX means they get up to speed quickly even without a tutorial. I’ve received considerable praise for how intuitive it is.
It’s developed in SwiftUI. My first time working on iOS. My experience is similar to others. 75% of the time, it’s a joy to use. 25% is spent pulling my hair out over internal bugs and bad documentation.
I think a mobile app should have a stupidly simple UI instead. Designers traditionally use a graphics program to design pixels. SwiftUI let’s you design layouts and components. Maybe designers should change how they design and start using SwiftUI as a design tool.
Modern development, at some companies, can truly feel regressive at times.
decoupling is hard to do and i was shocked (and gratified) they backported async/await... but swiftui is ui-level, im guessing there must be some real pushback for backporting it...
as a customer/developer, the whole os release every year is getting kind of old tbh...
I agree that Apple’s documentation needs help (this year’s improvements are a nice step) but can we really expect them to provide extensive documentation for handling edge cases (you’re telling me UIKit docs offer that)?
Forcing myself to be rational "hate" is probably too strong a word. If you are down the Apple cul-de-sac there is really no turning back. So investing in things like code examples for all of their API (there are a few, a very few) is a waste for Apple. It does not attract new developers and the old ones are stuck in the cul-de-sac.
There obviously is a trade off with how much you can/should expect, but "you cannot expect 9/10" is not a valid reply to "it currently is 3/10".
Meanwhile, my team has built an entire cross-platform desktop app in Qt with QML, which has been around for years and works refreshingly well. You're telling us that Apple, starting fresh and with several years under its belt now, still hasn't gotten its shit together with SwiftUI?
And the word is that nobody at Apple even understands how Xcode works at this point. It's a patched-together shitshow that desperately needs a ground-up rewrite... but we all know how those go. Remember the "ground-up rewrite" of Finder we were promised several major OS releases ago? Still waiting.
No? I've never heard of this. Do you have any citation for such a promise?
Wired: https://www.wired.com/2008/10/rumor-apple-s-finder-app-to-ge...
Ars Tecnica: https://arstechnica.com/civis/viewtopic.php?f=19&t=99890&sta...
Also a quick search found this guy referring to it in 2009:
"I have always wished that I could change both the font and spacing between both sections and items. I was really hoping this would be possible with the rewrite of finder in SL 10.6."
https://macmost.com/forum/resizing-the-sidebar-font-in-finde...
WHOOPS
This seems extremely unlikely given your other uninformed comment: https://news.ycombinator.com/item?id=32650545
A couple observations:
- SwiftUI is really complex
It's going to take you at least a year to get used to the declarative way it works, and be able to make UIs without struggling to figure out how to shuffle data around. If you look at SwiftUI examples/code, most of the complexity is hidden, but it's there, and you're going to have to interact with it to do anything non-trivial.
- Is SwiftUI the way?
SwiftUI has enabled me to build out huge amounts of beautiful UI quickly – faster than anything I've ever used. But you will run into things you can't do, forcing you have to fall back to AppKit/UIKit. And the area where AppKit/SwiftUI meet will disappoint and frustrate you. I just got done refactoring a huge amount of my app to use the "AppKit App Lifecycle" instead of the SwiftUI App lifecycle since I need some specific windowing behavior. Now I can't use .toolbar, .menu, and other stuff, which makes things much more complicated for me, and forces me to think about both SwiftUI/AppKit. Switching mental models like that, and trying to remember all the intricacies of both SwiftUI and AppKit is rough.
--------------
Regarding the performance issues of this specific post, my guess is they put everything into an ObservableObject, and used @Published properties to get bindings for their UI controls. This means any view with a reference to the ObservableObject gets re-rendered when @Published values change. Instead you need to silo your changes, so your entire App isn't redrawn every frame. This goes back to the complexity – it's not straightforward at all.
> Surely on a modern computer you can redraw a couple of text fields at 30fps?
Yeah this is the tricky thing, with how (I'm guessing) the code looks, you would think it's only updating the text fields. But in reality it's probably re-rendering the entire hierarchy using the @EnvironmentObject. So the SceneKit view gets setup and rendered every update of the Slider.
------------------
I have real-time color pickers for changing all windows in my app. Same with font sizes. It's possible to make it work, you just have to modify your design (which is unfortunate).
> But in reality it's probably re-rendering the entire hierarchy using the @EnvironmentObject. So the SceneKit view gets setup and rendered every update of the Slider.
I get that this is slower than only updating the single value, but what I don't understand is why even this is so slow? Browsers can render the right hand side of this inspector UI (https://chsxf.dev/assets/posts/5/map-editor-with-inspector.p...) at reasonable speed even if you rebuild the entire DOM for the fields in the inspector. I mean, it's one checkbox, one slider, and 7 text boxes and a bunch of labels. What is taking so much time here?
No, this is actually the thing you should not be doing in SwiftUI. Ideally you text fields are not redrawing at 30 fps, actually, ideally nothing in your interface is doing this except when an animation is running and even then only the components that are animating. SwiftUI makes it really easy for you to accidentally start redrawing things that don't really need to be redraw far more often then you want, and that's how you get performance problems.
There is this: https://github.com/krzyzanowskim/STTextView for textkit2, but the author ended up writing his own text input client.
How did you do about providing autocomplete, etc?
Thanks!
I'm still at the beginning of that part, but I'm doing it myself with TextKit 2 as well.
> I've been researching this space for a while and syntax highlighting text editors are rare and sparse.
I had the same experience as you when looking for information on how to go about it. I've come to the conclusion that no matter what an editor/IDE is going to be an ugly beast. This gave me some comfort in just forging ahead and trying to make good decisions as I go. And since I'm doing this all as a native app, I think I have a lot of wiggle room.
As far as syntax highlighting, I just recently started calling into Zig (the language I'm building this for), and using the tokenizer to do basic syntax highlighting. I'll need to go a bit deeper into the compiler to do more advanced highlighting, but it's cool to have it working.
> How did you do about providing autocomplete, etc?
I'm not there yet, but these are the things I'm looking forward to working on. I'm currently working on sort of "core" things and trying to design them well. Things like the settings, window management, a command palette, etc. Getting them close to right early on seems important.
I don't really do very technical posts, but I'm trying to blog a little about it: https://austinrude.com/tags/zig-ide/. My biggest issue is second-guessing using Swift/SwiftUI and not trying to do it all myself with Zig, leading me to procrastinate. But I'm pretty far along, and think I'll probably release something eventually.
What you’d need to be careful off is ensuring your @State or @Published changes don’t too take too long to skip frames
On Android, at least, Compose feels fully baked to us. Our shop is fully committed to new development on Compose UI; bridging tools for legacy components work great, and they work great for hosting new Compose views in our legacy framework as well. The Compose team is engaged with the community, and is generally ahead of the ball on problems real engineers are having.
In addition to all that, the structure of Compose has led to its new tooling being used in a variety of other domains. Engineers outside of Google are wiring Compose up to TUI frameworks, to platform-independent view APIs, and even running Compose without any UI at all as an asynchronous programming framework.
I don't have any experience with SwiftUI to compare it to. As an outsider, I know that the naysayers are sometimes louder than happy consumers of a new technology. But I will say this: there's a whole narrative in the Android world pointing out that Compose and Compose UI are two different things. Compose is available to use and work with even if you never touch the concrete UI framework Google has built.
Does any equivalent narrative exist in the iOS world? Or is SwiftUI mostly just a UI framework?
People don't think about it, but UIKit now has ~15 years of effort put into it, and got a serious boost from its shared roots with AppKit (even though big chunks of UIKit were freshly written, its structuring and API design were largely informed by AppKit), which has history tracing all the way back to the 1980s. Of course something as fresh out of the oven as SwiftUI is isn't going to be able to compare in terms of polish or capability.
So for now I'm sticking to UIKit in the apps I'm responsible for. I think SwiftUI's day in the sun is coming, but it's not here quite yet.
That doesn't mean that there aren't issues with how it's being engineered and documented, though. It has serious shortcomings that need to be shored up, and hopefully that happens with its maturation.
Based on my experience, the UIKit dev experience didn’t start to reach the level of completeness it’s known for now until some time between iOS 7 and 9… at least that’s when I remember the number of “required” third party libraries start to steeply decline.
I was there for Cocoa development in Mac OS X 10.3. AppKit was not mature. I wasn't there but have heard it was less mature in '91 3 years into NextSTEP.
But it looks like the task was somewhat beyond the people who had the responsibility for rolling out SwiftUI at Apple.
We're several years in to SwiftUI.
Apple's in a tough spot now. I'm really glad I don't have anything too high-stakes dependent on it. (I only have a project with ~200 hours invested -- not zero! -- it's heavily UI, but it's tiny... maybe ~30-40 hours to port to UIKit, if needs be.)
Android variants all have things that iOS can only dream of having in five years (notifications was a fun one), just spread very unevenly throughout manufacturers. Samsung currently has a very good Android build.
Calling it the best is very far fetched.
When I switched from Android to iOS in 2016, I was shocked at how little was different, and I can only assume gulf has narrowed since then. A lot of features Android users just assume iOS users don't have are there: vendor-agnostic password manager integration, Safari browser extensions, Safari content (ad) blocker API (Chrome is restricting ad-blockers soon!), more complete home screen customization and widgets, lock screen customization and widgets (iOS 16, upcoming), custom third-party keyboards, grouped/customizable notification system, native console wireless controller support from all three consoles.
Features like granular privacy controls and screen recording (with the exception of some obscure Android OEM builds) debuted on iOS first.
I'd be skeptical with anyone declaring either platform "best," I think they're both roughly equivalent.
However, I do think that anyone who uses macOS is insane to go with Android. There are simply too many useful integrations between the platforms to ignore, combined with the fact that, even if the iPhone isn't the best phone, it's usually in the top handful of choices in terms the overall package.
(Tip: you can tap the screen on the right side to go to the next page.)
I'm well aware of different ways to swipe pages. The reason why the hardware volume buttons are so convenient for reading is because you just put your thumb on the volume/page down button, and you no longer have to move it at all - only press down slightly every now and then. It's much more ergonomic for long-term reading than having to raise the thumb every time, even to tap.
You can imagine that someone might create malware or otherwise hostile app that plays a loud/embarrassing sound and hijacks your volume buttons.
Having to lift a finger to turn a page seems like a really small problem in comparison to that one.
Smartphones are general purpose devices and have to make tradeoffs like this all the time. They can't just greenlight every useful function that every type of app might want. IMO if you want an e-reader, get an e-reader.
For example: Let's say I'm a private detective. It might be nice for there to be an app that records audio and video at all times without any visual indication of my phone doing so. However, having that kind of OS level permission available to apps on an app store is probably a bad idea. I'll need to go out and buy a dedicated recording device.
Sure, we can argue about where the line gets drawn. If you like Android for allowing apps to modify hardware buttons, fine. But, I would prefer a device where physical buttons perform consistent functions. A middle ground might be some kind of buttons dedicated toward custom or app functions – but, to me, why bother when the entire screen is a customizable button?
Either way, this was meant as an illustration of how small factors can affect decisions. I have had an iPhone as my primary phone for a few months, and this one thing was the single biggest issue I had with it at the end of the day - not that there weren't others, and some were actually more annoying when they happen, but this one is at the top because it's something that's constantly in my face. Thus, I'm not going to buy another iPhone for this reason alone; my response to "you're holding it wrong" is "you're making them wrong".
Desktops, and Android, have allowed you to do this for decades.
Icons are lined up left to right, in a row.
You need to insert icons inside a row and then all the other icons to its right will be pushed right and/or down.
Just talking about being able to grab an icon and position it anywhere I want on the screen (possibly snapped to a grid).
Right now, icons have to be aligned in rows anchored in the top left corner, so that whenever you insert a new one, all the ones after that get pushed right or down, messing up your entire layout.
We've had this ability on desktops since Windows 3 thirty years ago, and Android has had it since day one. As does macOS. Why not iOS?
Here is a thread on reddit describing it:
https://www.reddit.com/r/ios/comments/r2vs1x/why_cant_you_pu...
There are a few solutions around it, some require a jailbroken iPhone, others use empty widgets to create "fake space".
Do you have a screen shot that could illustrate what it is you want to be able to do?
They're not all stacked up starting at the left corner, are they?
Imagine that all I want is three icons on my home screen, all lined up on the right edge of the screen, where they are easy to reach by my thumb.
You can't do that on iOS.
But now that you finally gave a concrete example of what you want to do, I can at least picture it.
And, yes, it would be really nice if Apple had a system to install third-party launchers, there's no denying that.
I know this is really silly, but you can definitely workaround the issue and effectively have the same end result as Android if you really want it:
Overall, every individual omission from one platform to another is going to be a question of what is important to the buyer.
For some, it might seem ridiculous that, in fifteen years, Apple still doesn't offer a truly customizable home screen. That's a fair criticism. At the same time, it's a fair criticism that it took until 2021 for Google to release a phone that will get 5 years of security and feature updates (Apple never guaranteed this directly, but the iPhone 6S delivered that level of support from when it launched in 2015 until the release of iOS 16 this fall that will drop iPhone 6S support: 7 years of full feature and security updates).
Meanwhile, if you bought a Pixel 3 in 2018, you got your final update this year. I personally think that's downright unacceptable considering the maturity of smartphones when it was released.
The problem with me making comparisons like this is that they'll always seem like a cheap whataboutism, but that's generally how these feature-to-feature comparisons work. For me, in 2016, I saw a situation where Google was not delivering everything I needed in a smartphone, but I also recognize that other people have other needs.
For example, I put the apps that I use the most often on the right hand side of the screen, where my thumb can reach them faster. I can't do that on iOS (well, I can, but then any new app I put on the home screen will mess the entire arrangement and I will spend another ten minutes calculating what to insert and where to get all these icons back on the right side of the screen).
I just don't understand how Apple, a company that prides itself on great user experience, is still putting their users through this UX hell fifteen years after the release of the iPhone, and they don't seem to think it's an important feature to add.
They trade blows in different security features.
This is a bit of a simplification but in broad strokes it is kind of correct. And it turns out this actually makes good UI!
You can install creaky old Windows on millions of devices with disparate hardware configurations on the day of its release, but Android users must wait weeks, months, or forever for their telcos to dribble out hacked, proprietary versions of Android for every model of device ONE AT A TIME. Seriously, WTF? And this is from the great "open-source" OS that was supposed to free us all from vendor and telco tyranny.
What a fraud.
Apple would have the same problem if iOS was open source and distributable by anyone, their chips being able to be made by anyone. Once again, Apple has picked the easiest (and least open) path, so, yeah, they can upgrade easily.
https://source.android.com/docs/core/architecture/hal-types
The big lift here was scrapping the Linux driver model which was at the root of most of the pain.
Power efficiency, absolutely, and a lot of this is due to them not really giving a damn for a while. Which was great! You truly could do anything with your phone, run things in the background forever, etc. Nowadays, Doze, Android Resource Economy and the need to go through Foreground Services/WorkManager makes it quite a bit harder to do.
No, it's just not important to you.
Garageband seems to be pretty popular on all the iOS form factors. iOS has for most of its life had a strong offering of music composition and production apps. iOS has had a high quality media framework for years, Android has not.
And if the need is so questionable, why did Android finally get around to addressing it?
And this seems like an odd argumentative path for an Android fan to go down - downplaying the importance of more niche needs outside social media and cow clicking as not important. iOS does just as well or better for messaging, Instagram and TikTok. If you only care about the smart phone basics for the masses iOS ecosystem is pretty hard to beat with better battery life and support.
I would say this is a matter of opinion.
Resting on laurels, while trying to figure out how to destroy everything good about macOS by making it more like iOS.
It stagnated enough for android to come really close, while the other issues didn’t improve much (side loading will be on Apple’s dead body, default apps setting still being too few), and there is no end in sight to the constant nagging for more service revenue.
Nowadays both OS are mostly on par, for instance android 13’s per app language setting is one of those QoL things that were iOS’s turf but are now more prominent in android.
Some of its features are yet to appear on iOS.
When the iPhone came out, that was the dominant landscape: PDAs and horribly incompetent phones. Internet browsing meant WAP (a clumsy attempt to dumb Web pages down enough to show on tiny, all-text phone screens) or a Blackberry. Blackberry rested on its laurels and a shitty, shitty browser until dead.
There are plenty of things that Apple remains bafflingly ignorant of, or just petulantly refuses to fix on its mobile devices. Great example: The iPhone, after 15 years, STILL doesn't notify you of missed calls. That's right: You don't even have the OPTION to get audible alerts of missed calls, but meanwhile you can get up to 10 alerts of missed TEXTS. That is simply stupid.
Then came the Apple Pencil... and no support for it in iOS. Every app developer had to implement handwriting recognition independently. WTF? Why didn't Apple simply allocate a square area in the on-screen iPad keyboard to accept written characters, which Palm OS nailed in the '90s?
Annnyway... I looked up Symbian because I work in Qt a lot now, and it was originally from Nokia. I knew it had been developed for phones, but could not imagine why. That's because I didn't ever interact with Symbian or see it in the wild and know it was from Nokia. So thanks for the note. I think Qt is pretty cool, and my team just made a good desktop app with it. I'm curious why the C++ Symbian experience wasn't good.
https://en.wikipedia.org/wiki/EPOC_(operating_system)
Symbian C++ had a couple of issues, namely several restrictions of accomodating C++ for a microkernel, before the days of C++98, and organically growing from there.
So there were several idioms and restrictions on how the language could be used, and the toolchain went through several iterations, MS-DOS batch files, Perl scripts, Metrowerks based compiler, eventually replaced by an Eclipse based IDE (after a false start), Carbide.
Qt came later into the picture as Symbian was being modernized, and after a POSIX compatibility layer (PIPS) was added into the platform.
You had the security rules that iOS "invented", C++, Java and Python toolchains, being able to run http server on the phone, 3D support for C++ and Java applications.
But Symbian C++ was a bit of a pain (see link below), it was being modernized via PIPS and Qt (as mentioned), but then Elop came to Nokia, the famous burning platforms memo came out, and everyone went away.
Nokia development culture was pretty much anti-MS, so most went elsewere, instead of bothering with Windows Phone 7.
http://symbian.tomuta.ro/GUID-C3206E31-251C-4AFC-90C2-04B38C...
So I wouldn't consider iOS the best mobile one in that regard, as probably no one that suffers being brought sundenly to the home screen due to pointer errors in Objective-C.
OS utilities like Image Capture, Preview, Apple's screenshot utilities, Spotlight, Quick Look, and quite a few others have been basically "killer apps" that make me want to use macOS over Windows for decades now.
Even basic areas like system settings have been a point of frustration for Windows for an extremely long time now, with Microsoft taking many years to truly migrate off of the Control Panel and deliver something half-decent in the Settings app. The Windows 11 iteration finally starts to feel like it's a little bit cohesive (but I still hate the Devices settings panel). The whole situation has really been a mess going back to Windows 8.
Another example: anytime someone says that printers universally suck I know immediately that they're Windows users because of just how much better Macs interact with printers and scanners and how much better and more reliable their configuration interface is. Apple single-handedly saved the entire printer industry from the depths of hell with AirPrint, before that Bonjour, and before that shipping OS X with preinstalled printer drivers.
Windows 10 couldn't decide what screenshot app I was supposed to use, thank goodness it's been consolidated after Windows 10's inclusion of two separate apps both worse than Apple's tooling.
Plus, Apple has to get credit for the sheer number of decently high quality non-enterprise apps that Apple just gives you for free.
Microsoft doesn't make anything that approaches the quality you get from Apple's free iMovie, Photos, Podcasts, Books, iTunes/Music, Contacts, Mail, Pages/Keynote/Numbers (without paying).
Finder on the other hand...
For the rendering part, it depends, I'd say it should take between 0.5 and 2ms with many layers, a lot or transparency and not much care for optimization.
Perhaps surprisingly, the most expensive part is usually text layout and rendering - text shaping is just really expensive and in the industry standard libraries it can take a long time to lay out a string, so you have to aggressively cache and do fancy things to get good performance. ASCII text is fast, though.
I don't see why all of text layout calculations could not be done at maximum speed with everything in L1. Probably with quite a few branch miss-prediction, but still.
The amount of work you can achieve in 1ms on a modern CPU is astonishing.
And to be fair, more than 90% of those symbols are very likely to be plain old ASCII...
Rendering is not why SwiftUI can be slow.
If you don't know what you're doing, it's possible for SwiftUI to think your new view is unrelated to the old view and everything needs deallocation and reallocation.
Based on the author's description, it sounds like the real cost here was from way over-diffing a set of models that weren't very efficiently bound to the UI. This is a very common source of bugs in all declarative frameworks.
In SwiftUI, the consequences can be particularly bad, because there are a couple somewhat innocent-sounding ways of injecting dependencies into your UI that actually invalidate the whole thing on any value's change and cause major updates (including, if a custom "Representable" that uses its own GPU tools is not implemented carefully, potentially reallocating all kinds of buffers and drawing tools).
This is all stuff that you learn how to deal with as you get used to the framework and learn its more advanced tools, but adapting to this part is not really something there's a lot of documentation for.
Very unexpected things happen, like items in a specific region in the App UI stop responding to clicks next time once you interact with them.
However I find it fine on iOS and the issues are usually around Apple changing something in the behaviour of the UI or API and breaking it, then you need to fix it for specific versions of the iOS. That's what you get when a framework is not mature yet, I guess.
That said, I don't think there's a turning back. It might be buggy but it definitely feels like the right way of building UI.
Oh, about the performance, you can build very sluggish or very responsive UI with SwiftUI because there's a night and day performance cost difference between "re-calculating and re-drawing" the UI and adjusting a property of it. Always try to structure your components in a way that changes happen by changing passed values instead of inserting or re-doing the views.
SwiftUI works quite a bit like React, many performance lessons from React will translate into SwiftUI.
The reason is platform coherence and control, and lock-step updates. To avoid cases like this:
https://segmentfault.com/a/1190000040213084/en
https://ntdotdev.wordpress.com/2021/02/06/state-of-the-windo...
...and not the insignificant money that could be made from devs updating a laptop a little earlier (especially since you can trivially use a still supported 5-6 year old laptop anyway with the newest Apple OS, and you wouldn't see any major performance issue, except in cases like the Intel to ARM switching. So what would they gain? Developers forced not to use an 8 or 10 year old laptop? As if they would?).
In the case of Magic Mouse, there's really a case of holding it wrong too. People hold it wrong and thats why they also complain about the ergonomics.
Truly excellent but misunderstood product.
Also if most people can't just pick up the mouse and use it, it's a broken design. In my particular case, it's so much smaller than my palm that I'm sure any grip would result in RSI.
Changing the design to accommodate a port in the front doesn't make sense because the primary function of the device is to act as a human-computer interface and optimising the design for that purpose is paramount, charging is not a primary function but something that we have to do with electronics and as a result having long battery life and short charging process is good enough solution(the battery lasts about a month, charging takes about 2 hours but will work for hours even with a few minutes or charging). Why would you compromise a design for something that needs to be done occasionally and can be done out of the service(i.e. at nigh, when not using it).
Also, we don't agree that the magic mouse is good human-computer interface because I'm starting from the position that causing physical pain automatically precludes it from that category. Another example of an interface in the same position is laser keyboards. They're also very cool designs, but the the fact that tapping on solid surfaces starts to hurt after awhile precludes them from being 'good' HCI.
I mean, if you really think that charging a few minutes a day or leave it charging overnight once a month is a deal breaker, simply don't buy it but this is not a bad design. It is very unrealistic to expect that the mouse will be used 24/7 every day forever. If you have this use case of using mouse 24/7 everyday, this must be some kind of industrial operation and obviously this mouse is not for you but for everyone else it's a non-issue.
Anyway, hopefully we can avoid wild mischaracterizations here. My expectation obviously isn't that things work 24/7 indefinitely. Think about how the typical user is going to discover that the battery is low. Either they'll get the notification just before it dies and have to charge it "soon" [1] or the mouse will simply die and force the matter. In some cases (think multi-user computer labs), the person who receives the notification and the person who has to charge the mouse might be two different people. I think it's reasonable to find waiting around on a mouse rather than whatever they were planning on doing irritating.
[1] https://apple.stackexchange.com/questions/254703/get-low-bat...
I had the occasion where the battery died by surprise. That’s why I keep repeating that the device works for hours after few minutes o charging, you don’t have to fully charge it before use.
The next one: the charge lasts a month to six weeks with normal use.
Next one after that: it's your unlucky day and you didn't idly think "oh, hey, I'll plug this in over lunch" on week three like a normal person. What you do is plug it in, and take a ten minute break. Everyone has ten minutes worth of things they can do. This gets you to a real break, and now you're good for another six months. Yes, I said months, just plug the damn thing in sometimes. Set yourself a reminder. Don't be a vegetable.
The amount of time you've dedicated to being irritated online about a product you don't use, is longer than the irritation a typical user of that product will experience the entire time they own it.
Congratuations, I guess.
Anyways I'm not irritated. This conversation was started because I asked what the good reasons behind obvious design issues are. So far the conversation has been about how you can work around them. That's great, but not the point.
Well, that's the broken design part.
>Changing the design to accommodate a port in the front doesn't make sense because the primary function of the device is to act as a human-computer interface and optimising the design for that purpose is paramount
There's nothing about HCI that prevents a different design.
In fact, the Magic Mouse is one of the least ergonomically optimized mice out there...
Then fire Jony Ive and make the front thicker! This isn't exactly rocket surgery.
This is in contrast to focus follows mouse, which you really can't do, and I wish it weren't so. In general though? The OS provides a lot of affordances for automation and customization, it exposes some of that through preferences and leaves the rest for developers.
A good example is what you can do to the keyboard from System Preferences (which is quite a bit) vs. what you can do using Karabiner.
Well, apps using it get a uniform look, that uniformly changes when the OS look is updated so that it matches it, and more importantly, they and also get to have the same widgets and widget functionality [1].
Unlike, say, Windows where you have 20 generations of MS GUI lib versions, with different looks and behavior, running at the same time, even from MS apps themselves...
[1] Yes, Apple has its share of inconsistencies (e.g. Swift UI vs regular Cocoa UI). But nothing like what would have resulted if they allowed apps with different historical macOS UI libs/versions to be installed at the same time independently from the OS UI libs.
Not completely orthogonal, as several different generations of MS GUI APIs implement different look and feels.
And bundling it with the OS means devs aren't forced to update their apps to the new APIs. It also makes it impossible for MS to automatically switch the look and feel (they could try for trivial things, but they wouldn't be able to properly accomondate old UIs based on pixel positions, nor would they be able to offer many of the new features given older widget designs).
https://segmentfault.com/a/1190000040213084/en
https://ntdotdev.wordpress.com/2021/02/06/state-of-the-windo...
Also apps don't get the new "improved" styles etc if they don't have it in the system, which takes away the consistency Apple aims for.
And then: It's Apple ...
Apple's not doing the correct thing. SwiftUI just created a barrier where people pre-iOS 13 lose access to a lot of apps, and those apps will be raising their minimum version a lot more often than before. So if anything, you could consider this a ploy by Apple to get people to upgrade their phones.
That is the whole point of Jetpack libraries, to ship newer versions of Android with the application, with polyfills, as the OS updates will never happen.
I've been able to workaround this by sticking a .id() on the view in question, I've seen similar issues with views falling out of the keyviewloop when you have a bunch of dynamic forms.
If the bugs are bad enough I can always do something custom in UIKit via UIViewRepresentable.
The current project that I'm working on, is pretty big. It peaked at 40 screens, but I'm trying to get it down to half that.
I've been working on it for two years. I also wrote one of the backends (and most of another).
There was no way that I was going to start on a project of that complexity on SwiftUI, which, at the time I started, had only been demonstrated in a few small projects. I already knew that UIKit could do it.
But I think that SwiftUI will become the standard, sooner or later. I look forward to being able to write more reactive applications in it. In my experience, if I use UIKit, it's a fairly bad idea to stray from the old MVC model (This, I have learned. <Pulls up shirt> See this scar?).
I hope Apple never goes the way Microsoft did with their fad UI toolkits that utterly destroyed developer trust in native Windows development (MFC, WinForms, WPF, UWP, WinUI, .Net MAUI). They are pretty wise for keeping SwiftUI be the "for kids" vanity UI toolkit to lure in React webdevs, while keeping UIKit and AppKit for serious stuff.
At WWDC 2022 they specifically said that Swift+SwiftUI is the best way to build apps, and the future of their platforms. I thought AppKit/UIKit would stick around, but I guess not.
---------------------------
Edit: Here's the direct quote from the "Platforms State of the Union":
> We're continuing to expand our adoption of SwiftUI across our apps and system interfaces. For example, iOS's new Lock Screen widgets were designed from the ground up using SwiftUI. The new Font Book app was completely rewritten with it. And the modern, forward-looking design of the new macOS System Settings app was built using it. Swift and SwiftUI were designed from the start to provide a single, native language and API for all Apple platforms. You can learn them once and apply them everywhere. Whether your vision is to provide quick access to information at a glance on Apple Watch, productivity tools on MacBook Pro and iPad, new experiences on iPhone, or a new way to relax with Apple TV, Swift, SwiftUI, and Xcode provide a next-generation integrated development platform to help you build apps for all of our products. Now, if you have an existing app, it's easy to adopt these new technologies incrementally. And if you're new to our platforms or if you're starting a brand-new app, the best way to build an app is with Swift and SwiftUI.
The slide had a Swift, SwiftUI, and Xcode logo with nothing else.
I know, for a fact, that some AAA applications are still using ObjC.
Also, I am quite sure (but don't know) that Apple still has a plenty big ObjC codebase at home.
Either that, or Electron/Xamarin/React Native.
I am not really a fan of the hybrid apps. I was just watching Slack go crazy on my iPad, a few minutes ago.
Funny story. It started off as Object Pascal, and used MacApp 0.9 as its framework.
I think the codebase was converted to C++, around Photoshop 3.
Snapseed[0, 1] (won awards) had its engine written in C++.
C++ is a good language for image pipelines. Doesn't really pass the "ooh, shiny!" test, though...
[0] https://apps.apple.com/us/app/snapseed/id439438619
[1] https://play.google.com/store/apps/details?id=com.niksoftwar...
https://computerhistory.org/blog/adobe-photoshop-source-code...
Having said that, even though Apple indicates it will turn, it still may change its mind halfway through.
What Apple says at their circus show is not the same weight as the captain of a ship telling you the ship's course.
> The Objective-C language, AppKit & UIKit frameworks, and Interface Builder have empowered generations of developers. These technologies were built for each other, and will continue to serve us well for a long time to come, but over time new abstractions become necessary. For a while now, you've seen us hard at work defining the next generation of integrated language, frameworks, and tools: Swift, SwiftUI, and Xcode Previews.
>
> Tight integration in a development platform like this requires that all three pieces be designed and evolved together, both driving and driven by one another. Swift result builders were inspired by SwiftUI's compositional structure. SwiftUI's declarative views were enabled by Swift value types. And Xcode Previews was specifically designed for, and enabled by, both. Now, the result is the best development platform that we have ever built. And this year, Swift, SwiftUI, and Xcode all have fantastic updates that take this vision further, and make it even easier for you to build great apps for all of our platforms. And it all starts with Swift. Now Ben from the Swift team is gonna tell you all about what's next.
I'll start getting concerned when they rewrite any of their serious apps in Swift(UI). (i.e. Logic, FCP, Xcode, Finder, Instruments, iMessage, Mail, Calendar, etc.)
But if you don't keep track of the impurity dependencies on your language, you will need to rediscover those dependencies during compilation, and besides surprising the developer all the time, that's a really nasty problem to solve. That's why it's always solved badly.
However for a real nice C++ GUI development experience on Windows, going with C++ Builder or Qt would probably be a saner option, as the WinUI team doesn't seem to get it, and MFC only gets minor updates nowadays.
WinForms is basically Delphi's VCL ported to .NET. And back in 90s, Delphi was one of the most popular ways to make native Windows desktop apps.
Apple's sell for SwiftUI was "it's like going to a chef who knows how to cook for you" instead of "cooking yourself". But is that really a good thing? Do we really want to be taking less control of our applications when we write them?
The worst part is all these tutorials that have to combine SwiftUI and UIKit because the former is very buggy in certain cases, like navigation trees on iOS have really janky animations using SwiftUI. So you have to coordinate all your Views using UIKit. It just seems barely easier to use SwiftUI most of the time.
EDIT: Basically, in summary, it seems like a very complicated (look at the crazy language features they had to add for it) plus very opaque ("it magically does it for you just how you wanted") way to write the same apps you were already writing fine in UIKit and AppKit
> SwiftUI came about because someone who has never been a software engineer
so... management?I recently began developing with Flutter for a project. And whilst I dont love Flutter/Dart that much, I must admit that Google have done an amazing job of proving resources and documentation for the frameworks!
The whole Flutter community and available resources feels very rich, welcoming and embracing!
Tech like Flutter is fresh and exciting to a lot of people, and Apple is right to be worried!
So say what you will about Flutter/Dart, love it or hate it, the docs and community are excellent!
There’s a lot more variety of learning resources compared to other languages; there are texts, workshops, videos, code labs, etc. It’s also nice seeing members of the Flutter team facilitate some of the workshops themselves; it’s refreshing to see developers being involved in educating users, instead of ‘outsourcing’ everything to others.
That... is exactly the same thing with React. You don't notice everything is redrawn until suddenly everything is unbearably slow. And then it's useMemo etc. galore.
I'll withhold my judgement on SwiftUI for now though.
I have never fully bought into this notion that the components should rebuild themselves in this kind of stateless manner.
I think this like an intellectual obsession with functional programming mapped onto the UI Tree. I can't fathom why it's 'better'.
The reactive aspects of the middle tier of the program - that's progress. But the reactive components, I'm not sure about that.
To write code quicker, and make it easier to maintain. If it's a moderately complicated UI, then I could code it up much faster in React (my guess is around 10x). IMO, React isn't about functional programming, it's just a good DSL for writing UI.
React Native doesn't seem to have any degree of simplification vis-a-vis regular Android Views for example.
On the web - that's a different story entirely, but when doing strict comparison I just don't really buy it for mobile apps.
The amount of code is similar, but with React you have to deal with extra layers of abstraction, and some things are obfuscated by the framework. No performance gain and often a performance lost.
It makes the easy things easier. A common problem for these sorts of tools. It is help with the hard things that we need.
Edit - I have experience with SwiftUI not React.
Yes, it's faster to write. Is it easier to maintain? Doubtful. Especially when you inevitably run into issues that your whole UI re-renders a couple of hundred of times a second, and you have to go in and butcher everything with useMemos, caching etc.
On the web frameworks like Solid.js are exploring these fine-grained reactivity approaches to actually re-render only what's needed, and not huge chunks of UI
Well done
After two years with Xcode/Swift/SwiftUI I never succeeded in getting anything useful out of the profiler.
Following the instructions from "blogs", official videos, and what official documentation exists
> Do you have past experience with how to profile and optimize applications?
Yes. About three decades
The tricky part is knowing what is immutable, because standard JVM collections are not.
I ended up implementing a similar rate limiter, I think based on this here: https://weblog.west-wind.com/posts/2017/Jul/02/Debouncing-an... (I've never shipped it though.)
The art is to get the behavior just right. You want the first request to go through immediately, so on a single click the user sees low latency. But afterwards you need to throttle it so that it only updates every, say, 500 ms. And you must not forget to display the very latest state, if there is no new event after e.g. 50 ms.
This seems like one of those things that are really hard to get right and the toolkit developer should have solved for you. I've struggled with it a couple of times now.
And in both cases, still not up to the set of WPF capabilities in that regard.
The issue is that Apple sort of claims that this is all you really need to do, and that the framework will kind of handle it for you. In reality you need to be really careful about what's being updated to avoid spurious updates. Actual SwiftUI code for anything non-trivial necessarily requires some manual debouncing and equatable checks. I hear React Native often has the same issue, but there people have experience with applying memo when necessary. With SwiftUI it's considered "advanced" and bites people before they really know how to deal with it. And, of course, that's assuming that the dependency graph is working correctly: if it's not, you're often stuck and there's often not much you can do.
React and Jetpack Compose aren't so lucky, having to rely on the underlying optimizations of JS engines and ART, on escape analyis and GC algorithms.
I never understood the love for reactive for interactive GUIs, when they are so bad in memory management and its effects to jank.
Also, aren’t they basically push-based reactive frameworks? I would assume they just call a bunch of registered functions and that’s it. The graph itself shouldn’t change too often (and may be static as well, eg. React vs SolidJS) — but I am way out of my depth here.
The most performance code is the one you don't have to execute.
In my experience, you definitely have to minimize work done in Views and maybe avoid `@Published` properties on your model in favor of more explicit calls to `objectWillChange.send()` to signal when you really are ready for the Views to be updated. SwiftUI does not seem to do a very good job of coalescing by default.
If all you want is a declarative UI, just dump in ImGui and be done with it.
btw, please add an RSS feed to your site. If you have one it's not discoverable via in-page links, link tags, or educated guessing.
.onAppear {
// 0.05 is a guess. anything lower seems to run too early
// and does not have the desired effect.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
focusTextField = true
}
}
Similarly, dismissing text field focus & on-screen keyboard upon scrolling/tapping away is a source of programming pain. It seemingly was bad in the old APIs. It is worse in SwiftUI in my limited experience. Same for scrolling a view such that an active text field isn't covered by the on-screen keyboard.You have to look closely to new requirements that they roll out every few months. You should use Apple products in your app or gtfo (e.g. login with Apple ID). You have to update your laptop every few years because Xcode (which is monumental PoS) requires new MacOS that your hardware doesn't support. And when you go through all this trouble, you have to literally beg Apply to admit a new version of your app. You even have to pay Apple to be able to write apps for their phones/tablets.
I'm so glad I jumped off iOS development a few years ago.
If you're a young developer and still not decided what area suits you the most, think twice before entering iOS and MacOS development.
The only thing I want is to develop an app for my own use, but I need a paid account if I want an app that lasts long.
I haven't really coded things since I was a kid and since I have an iPad/iPhone/iMac and wanted to learn how to code again and potentially use it as a side hustle or some sort of future money making opportunity, I decided to learn swift/swiftUI and i'm currently taking an online course, but when I read through hacker news, all I see is articles bashing it constantly.
The tooling will always be less mature than you can find elsewhere. And in the end, all you have is a thing that works only in the walled garden.
Of course this observation is not limited to any particular garden.
Flutter is currently rewriting a key part of their graphics rendering pipeline as we speak that should clear up the remaining issues people seem to have with it when it comes to performance and the rest of the project is incredibly well supported and documented and most importantly as you hinted at genuinely cross platform.
It’s a much better bet for basically any project outside of one that you know for a fact is only ever going to target Apple operating systems.
1. SwiftUI seems mainly suited for building quick proof-of-concept simple intro apps, with the difficult 20% still out of reach. Which doesn’t sound all that different from the notorious downsides of cross-platform frameworks, some of which can allow for small simple apps to be quickly spun up, but the tough under-the-hood cases still intractable.
2. Flutter, and React Native are more mature than SwiftUI is right now. SwiftUI will get there, and maybe it’s only 1-2 years away, but it still hasn’t hit its Swift 5 moment yet. That opens up the possibility of breaking API or even conceptual changes until then.
Source?
The lack of support for Video and Camera from SwiftUI was the most challenging part for me as a newbie Mac dev.
Took me a few weekends to get the core part done (ML and algorithm), but hooking up all the UI components and connecting them with the video stream gave me so many headaches.
With that said, it was still much easier for me (complete newbie to Mac App at the time) to learn and develop in SwiftUI than UIKit.
Hope SwiftUI keeps getting better and keeps investing in the team.
Just an FYI.