News for hackers. Stuff that matters.
Re:How Swift 5.3 enhances SwiftUI’s DSL by dceddia on Sunday September 13, 2020 @02:34PM (#24462903)
I’m starting to learn macOS development and I’m a bit torn on SwiftUI. As someone who’s primarily done web development the last few years, and comfortable with React, SwiftUI is pretty appealing from the standpoint of being a similar mental model.

On the other hand, it doesn’t quite feel ready. SwiftUI seems to be missing enough components that I end up needing to know how to use the existing AppKit stuff with autolayout, or know how things work under the hood to debug SwiftUI oddities. On top of that, there are few resources out there for learning macOS dev specifically — tons of stuff for iOS, which sorta translates, but not perfectly. I’ve been learning from the Hacking with macOS book, which is very good, and plenty of trial and error.

The other ding against SwiftUI for Mac dev seems to be that it’s only supported in Catalina, and it seems an awful lot of Mac users have held back from updating, so the user base might be diminished.

Most of these seem like temporary problems, but as a newcomer to this world it’s hard to tell if it’s too early to commit to SwiftUI.

Re:How Swift 5.3 enhances SwiftUI’s DSL by kitsunesoba on Sunday September 13, 2020 @02:41PM (#24462950)
SwiftUI is definitely not yet ready, particularly on macOS. Under iOS it can get the job done depending on the app in question.

It's rapidly improving, though. The version of SwiftUI shipping in iOS 14 and Big Sur are massive improved compared to the current version. If Apple can keep that rate of improvement up, it will reach parity with UIKit/AppKit within another release or two.

Re:How Swift 5.3 enhances SwiftUI’s DSL by spideymans on Sunday September 13, 2020 @03:48PM (#24463416)
It's not too early to "commit" to SwiftUI. Just remember that "committing" doesn't mean writing every last bit of UI code in SwiftUI. At this stage, I think the best approach is to be using both UIKit and SwiftUI, and use whichever framework is better for implementing whatever specific features you're implementing.

For example, say I'm presenting a modal with a simple form. I'd use UIKit's UINavigationContoller to present the modal view, and within the modal's view, I'd have a UIHostingController which encapsulates the SwiftUI-defined form user interface. I can define form layouts (and other simple layouts) much quicker in SwiftUI than I can in UIKit, so I'm finding SwiftUI to be very helpful in that regard.

Re:How Swift 5.3 enhances SwiftUI’s DSL by saagarjha on Sunday September 13, 2020 @04:46PM (#24463832)
You must commit to not use SwiftUI if you support an older OS. If your deployment target is last year or newer, then do you have the ability to pick and choose.
Re:How Swift 5.3 enhances SwiftUI’s DSL by cschep on Sunday September 13, 2020 @06:00PM (#24464287)
Committing to iOS 13 is a lot easier than SwiftUI in entirety.
Re:How Swift 5.3 enhances SwiftUI’s DSL by coldtea on Sunday September 13, 2020 @06:13PM (#24464370)
>The other ding against SwiftUI for Mac dev seems to be that it’s only supported in Catalina, and it seems an awful lot of Mac users have held back from updating, so the user base might be diminished.

The majority updates fast - even more so when a 2nd update (Big Sur) comes out, few will hold to before Catalina.

With macOS it makes no sense to "hold out" from upgrading long. You are either prepared to get on with the program and move on, or you're left behind, worse than e.g. on Windows etc.

On the other hand, this makes the platform faster to move forward, adopt new things, and keep a more consistent UI doing so (Windows still have 5-6 UI layers from previous APIs/decades, depending on the app you use -- even for internal MS apps, e.g. you can still open an ancient version of the control panel from within the current one).

Re:How Swift 5.3 enhances SwiftUI’s DSL by pwinnski on Sunday September 13, 2020 @06:59PM (#24464654)
What you describe is the case for every MacOS upgrade except Mojave to Catalina, since that particular upgrade means losing access to all 32-bit apps.

I'm normally a pretty quick upgrader, but the MacBook on which I'm typing now will remain on Mojave until the day it dies.

Re:How Swift 5.3 enhances SwiftUI’s DSL by Twisell on Monday September 14, 2020 @06:09AM (#24468516)
In retrospect however this move made total sense. When they will start deploying custom silicon next year every application that run on Catalina will be able to run on the new ARM Macs.

From Apple perspective it's way better that Catalina take all the blame and not the new products and the technology they are betting on for the next decade.

Also developers that care about MacOS platform were even more incentivized to finally upgrade to 64-bits after the 10+ years deprecation warning so that more Apps will be ready on day one for custom silicon.

Re:How Swift 5.3 enhances SwiftUI’s DSL by simonh on Monday September 14, 2020 @08:24AM (#24469251)
The deprecation warnings started in 2018 with 10.13.4, not 10+ years ago.
Re:How Swift 5.3 enhances SwiftUI’s DSL by Twisell on Monday September 14, 2020 @02:09PM (#24473210)
While maybe true 64bits was available for more than 10 year with Snow Leopard (10.6) being the last OS supporting 32bits architecture (and dropping PowerPC support At the same time). So let's say you could have seen this coming.

https://en.m.wikipedia.org/wiki/Mac_OS_X_Snow_Leopard

Re:How Swift 5.3 enhances SwiftUI’s DSL by panic on Sunday September 13, 2020 @06:30PM (#24464478)
There are reasons not to upgrade. I'm staying on Mojave so I can keep using the 32-bit copy of Photoshop I bought years ago.
Re:How Swift 5.3 enhances SwiftUI’s DSL by wlesieutre on Monday September 14, 2020 @12:25AM (#24466740)
If/when you do upgrade, check out Affinity Photo or Pixelmator Pro for a non-subscription alternative
Re:How Swift 5.3 enhances SwiftUI’s DSL by dceddia on Sunday September 13, 2020 @07:58PM (#24465017)
Yeah, it probably depends on the audience somewhat. I know other developers who have avoided Catalina up til now (and I was one myself, until I got a new MacBook late last year), so that’s in the back of my mind as I’m thinking about making a tool for devs.
Re:How Swift 5.3 enhances SwiftUI’s DSL by vhbit on Monday September 14, 2020 @04:14AM (#24467934)
Read this before committing on macOS: https://steipete.com/posts/state-of-swiftui/
Re:How Swift 5.3 enhances SwiftUI’s DSL by jamil7 on Sunday September 13, 2020 @03:43PM (#24463371)
I’ve got two iOS apps in the app store that are mostly SwiftUI with some UIKit, it’s definitely viable but I recently tried working on an idea for a macOS app I’ve had for a while and was disappointed. Big Sur improves things somewhat but I’d recommend learning AppKit as well. The approach I’m taking is to use the overall SwiftUI structure but wrap a lot of AppKit views for the crucial UI elements, I figured I can replace the AppKit pieces easily later on this way.
Re:How Swift 5.3 enhances SwiftUI’s DSL by luxurytent on Sunday September 13, 2020 @04:46PM (#24463828)
Do you have any recommendations for articles that explain how to include AppKit with SwiftUI? I'm new to iOS dev and have been building with Swift/SwiftUI almost exclusively, but not sure what's the right way here just yet.
Re:How Swift 5.3 enhances SwiftUI’s DSL by jamil7 on Monday September 14, 2020 @02:24AM (#24467370)
Not really, unfortunately it's a lot harder to learn AppKit than UIKit due to the lack of online resources available. Try to find open source mac apps and read the source code and Apple's documentation are the only suggestions I can think of. I've seen a "Hacking with macOS" Udemy course that looks comprehensive although I can't recommend it as I haven't checked it out. With regards to wrapping AppKit views in SwiftUI the process is more or less the same as it is with UIKit.
Re:How Swift 5.3 enhances SwiftUI’s DSL by luxurytent on Monday September 14, 2020 @06:25PM (#24475841)
Thank you!
Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @02:52PM (#24463018)
I went pretty deep on swift mac UI development at some point but I was left disappointed. I've realized that building your own gui toolkit isn't that hard. Right now, I'm building my own toolkit in Rust with this Rust nanovg clone called gpucanvas https://github.com/cytecbg/gpucanvas.

Here's another nanovg based gui toolkit in cpp https://github.com/wjakob/nanogui

Thanks to Rust macros, you can shape the language to be essentially whatever you want.

I think that ECS (entity component system https://en.wikipedia.org/wiki/Entity_component_system) is the way go with GUIs.

Re:How Swift 5.3 enhances SwiftUI’s DSL by doteka on Sunday September 13, 2020 @02:55PM (#24463043)
Could you elaborate on what you found easy about writing a GUI toolkit? Not being snarky, but easy is the last word I would use to describe it.
Re:How Swift 5.3 enhances SwiftUI’s DSL by jitl on Sunday September 13, 2020 @03:03PM (#24463090)
UI programming - and GUI toolkit programming - is all about breadth. There’s a ton of things a UI needs to do, but most of those things are straightforward to implement, and there’s usually a plethora of lower-level libraries to compose in any given area. So, it does take a lot of work to implement a UI (toolkit) but not much of it is a stumper. And, many areas of UI toolkit functionality can be ignored or have low-quality implementation for a long time. For example, a hobbyist writing their own UI toolkit can ignore accessibility, but still end up with something usable by the hobbyist. Or, the initial implementation can use only absolute layout. Or, the initial implementation can use only a single fixed-width bitmap ASCII font.
Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @02:58PM (#24463055)
I didn't say easy, I said it's not too bad. Look at this toolkit for example https://github.com/yushroom/Fishgui. Once you have rendering (which nanovg handles), you just need some hierarchy, event handling, windowing and layout and you have a basic toolkit.

I like the control a lot, with Cocoa, I felt really constrained sometimes.

Re:How Swift 5.3 enhances SwiftUI’s DSL by millstone on Sunday September 13, 2020 @04:15PM (#24463623)
Now draw the rest of the owl!

A key point of a shared UI toolkit is that users can bring their knowledge from one app to another. A standard Cocoa table view or text view has tons of advanced behaviors: type select, keyboard shortcuts, etc. It's worth the user's time to learn these because they work in every app.

But apps where these don't work feel discordant and frustrating.

Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @04:20PM (#24463658)
You can mimic native behaviors. But these are different between say browser and native cocoa apps anyway.
Re:How Swift 5.3 enhances SwiftUI’s DSL by kergonath on Sunday September 13, 2020 @06:04PM (#24464310)
You won’t ever produce a perfect imitation. UIs based on third-party toolkits are always a pain, stuck in the uncanny valley. They look somewhat like they should, but have all sorts of quirks that break useability: text fields that don’t support standard shortcuts, weird layouts, wrong fonts, buttons that cannot be selected with the keyboard, etc.

It is much, much better to use Apple’s toolkits.

Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @06:23PM (#24464427)
How many shortcuts are there realistically? 50?
Re:How Swift 5.3 enhances SwiftUI’s DSL by samatman on Sunday September 13, 2020 @08:09PM (#24465115)
That's not the problem, the problem is that I can define a system-wide shortcut from System Preferences and it really is system-wide... unless you don't use the native framework, in which case I'm out of luck.

There are an infinity of little things like this. macOS is powerfully integrated across the platform and you either play ball with it or you don't.

One that's pretty important is accessibility. You're leaving the blind, vision-impaired, and paralyzed users out in the cold, because macOS has a fairly complete system for all those users to make use of the operating system. But it won't work for an app that isn't native.

Re:How Swift 5.3 enhances SwiftUI’s DSL by kergonath on Sunday September 13, 2020 @07:58PM (#24465020)
Probably around that by default, maybe a bit more: https://jblevins.org/log/kbd https://www.howtogeek.com/681662/35-mac-text-editing-keyboar...

But all of them need to work, along with system-wide custom ones.

Text substitution is also an issue.

Re:How Swift 5.3 enhances SwiftUI’s DSL by jen20 on Sunday September 13, 2020 @06:26PM (#24464452)
This is the precise reason I hate web apps with a passion. I want every app on my machine to behave predictably and have a uniform look and feel, not for every UI designer to be able to produce their own unique snowflake without regard for consistency.
Re:How Swift 5.3 enhances SwiftUI’s DSL by saagarjha on Sunday September 13, 2020 @04:47PM (#24463835)
This is why many people are frustrated by web applications that do not mimic features they expect from native Cocoa apps.
Re:How Swift 5.3 enhances SwiftUI’s DSL by nikki93 on Sunday September 13, 2020 @08:16PM (#24465177)
A certain genre of apps, especially eg. digital audio workstations, manage to do this and also have a sizeable userbase. Ableton Live is an example here. It seems especially sensible if your design does actually have a bunch of controls you need custom rendering for.

Honestly, don't let these comments get you down. It's important to act strategically of course, so it doesn't make sense to over-invest in an idea succeeding. But it makes sense to do scoped experiments / proof-of-concepts. I don't think we're "done" with UI framework architecture design, people need to keep trying new things in the space. And I also don't think only Apple (eg. SwiftUI) and Google (eg. Flutter) are allowed to work on these things and we need to accept their gifts from above. Some times, a good quality here is almost not believing that something is too hard to do (while obviously also informing oneself about as much existing work there has been as possible to incorporate it into the experiments).

Re:How Swift 5.3 enhances SwiftUI’s DSL by coldtea on Sunday September 13, 2020 @06:17PM (#24464386)
>you just need some hierarchy, event handling, windowing and layout and you have a basic toolkit.

Yeah. Once you add hierarchy, event handling, windowing, and layout to a rendering engine you pretty much have a basic toolkit.

Kind of like once you've hand built a cpu, gpu, logic board, hard drive, and so on, on top of 3d-printing a case, you have a basic PC.

Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @06:21PM (#24464419)
This is a basic toolkit in like 3000 loc https://github.com/yushroom/Fishgui. It uses nanovg.
Re:How Swift 5.3 enhances SwiftUI’s DSL by doteka on Sunday September 13, 2020 @06:22PM (#24464420)
That sounds like an insane amount of work to me to end up with something objectively worse from a usability standpoint. But to each their own.
Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @06:48PM (#24464576)
It's debatable how much worse usability is.
Re:How Swift 5.3 enhances SwiftUI’s DSL by filleduchaos on Monday September 14, 2020 @12:54AM (#24466884)
And what of accessibility?
Re:How Swift 5.3 enhances SwiftUI’s DSL by PaulDavisThe1st on Sunday September 13, 2020 @03:39PM (#24463340)
text input (right to left, left to right, compose chars) ?

tree views (with non-textual cells)?

nested menus?

file selection dialog?

Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @04:12PM (#24463601)
You should wrap native file dialogs. Text input direction isn't that big of a deal if your rendering supports it. Tree views are somewhat tricky but not that much harder than list views.
Re:How Swift 5.3 enhances SwiftUI’s DSL by pjmlp on Monday September 14, 2020 @05:34AM (#24468319)
How well does it actually implement each platform L&F (specially the feel part), does data virtualization, UI designers, support for disabled people and respective assistive technologies?

Drawing buttons and windows is easy, the problem is the rest.

Re:How Swift 5.3 enhances SwiftUI’s DSL by readarticle on Sunday September 13, 2020 @04:06PM (#24463550)
Does the lack of arthritic, farsighted Arabic speaking users factor into it not being too hard or is that whole mess already built into the underlying libraries?

UI platforms as a rule are always terrible, but there’s inevitably a whole lot of baby in the bath water.

Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @04:21PM (#24463664)
It depends. How does Cocoa handle arthritic users?

It's not baby with the bathwater, the second you want something cross platform, your choices are electron or qt? Neither is that great of an option.

Re:How Swift 5.3 enhances SwiftUI’s DSL by readarticle on Sunday September 13, 2020 @04:47PM (#24463834)
Common, customizable keyboard shortcuts & behaviors across the entire OS are huge for people with arthritis that can’t use a mouse, Automator workflows that hook in and take care of repetitive tasks are common and eventually Siri Shortcuts will be available on macOS like iOS.

Last year Voice Control: https://www.apple.com/macos/catalina/docs/Voice_Control_Tech... came out and is absolutely stunning and free with accessibility labels.

A custom UI would force them into “grid mode” on page 6 off the bat while it’s almost too easy if you just stay native, UI tests interact with the app through accessibility labels for example, and obviously we’re all testing, right?

Simply riding closely on the back of the behemoth that’s weirdly good about accessibility gets one very far, very fast.

Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @05:14PM (#24463995)
Too bad this behemoth doesn't care about cross-platform.
Re:How Swift 5.3 enhances SwiftUI’s DSL by readarticle on Sunday September 13, 2020 @05:47PM (#24464198)
Too bad disabled users don’t either.

Cross platform wasn’t even mentioned or implied in your original comment by the way, it was edited into the second one where you narrowed an “arthritic, farsighted Arabic speaking user” into “arthritic”.

Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @06:23PM (#24464438)
It wasn't mentioned but that doesn't mean that I don't care about it.
Re:How Swift 5.3 enhances SwiftUI’s DSL by codetrotter on Sunday September 13, 2020 @11:05PM (#24466350)
I used to be very strongly in favor of cross-platform but I have come to realize that in a lot of cases that while it is true for us as developers that cross-platform is great because it means a bigger audience, it is easily worse for your users.

I’d rather pay $50 for a native macOS application that uses the UI toolkits offered by its platform and respects the conventions and the system as a whole, than to pay $5 for an application that allegedly does the same thing but which feels broken, sluggish and/or incoherent because its developers are making something cross-platform.

There are some exceptions to this – some developers do pull it off, and if what they make is both good quality and performant and the tool is offering something of exceptional value to me then I will use it. But in the general case, I will avoid the non-native experience.

All of that being said, I still think it is cool that people invest time in exploring making their own GUI frameworks. All I am saying is that it has a cost for the users a lot of the time.

Re:How Swift 5.3 enhances SwiftUI’s DSL by pjmlp on Monday September 14, 2020 @05:39AM (#24468349)
It does, when one uses toolkits that wrap platform APIs.
Re:How Swift 5.3 enhances SwiftUI’s DSL by ajconway on Sunday September 13, 2020 @06:12PM (#24464365)
The other choice is to share business logic, reimplement UI for each platform independently, using platform-specific APIs.

Cross-platform GUI always leads to compromise.

Re:How Swift 5.3 enhances SwiftUI’s DSL by pjmlp on Monday September 14, 2020 @05:40AM (#24468352)
Yes, this is definitely the right approach for native apps.
Re:How Swift 5.3 enhances SwiftUI’s DSL by adamnemecek on Sunday September 13, 2020 @06:23PM (#24464434)
I disagree.
Re:How Swift 5.3 enhances SwiftUI’s DSL by yoz-y on Monday September 14, 2020 @06:55AM (#24468738)
At the very least I’d recommend using SwiftUI instead of Storyboards. Even if all the rest is done in UIKit/AppKit
Re:How Swift 5.3 enhances SwiftUI’s DSL by atarian on Sunday September 13, 2020 @03:19PM (#24463209)
I'm looking forward to when you can just build an app once and use it across iOS and Mac right out of the box. Catalyst seems like a good first step in that direction.
Re:How Swift 5.3 enhances SwiftUI’s DSL by kitsunesoba on Sunday September 13, 2020 @04:01PM (#24463508)
SwiftUI universal apps do this even better by automatically using the appropriate backing controls for the targeted platform — e.g. a SwiftUI `Button` translates to `NSButton` on macOS and `UIButton` on iOS.

I think it's ultimately what Apple intends to make the flagship way to develop on their platforms. Catalyst exists mostly as a way to pull existing iOS apps and iOS developers under the Mac umbrella.

Re:How Swift 5.3 enhances SwiftUI’s DSL by PostThisTooFast on Tuesday September 15, 2020 @04:13AM (#24478975)
Yes. Catalyst is a kinda-clever but janky solution. It basically puts the iPad simulator on the screen.
Re:How Swift 5.3 enhances SwiftUI’s DSL by choxi on Sunday September 13, 2020 @07:44PM (#24464919)
I wrote a post about my experience using it for a year if you're curious: https://getglyph.app/blog/3-building-glyph-a-year-with-swift...

I didn't speak to developing for macOS specifically. The tldr is that it's not quite production-ready but it's easy to mix SwiftUI with UIKit so you can adopt it incrementally. I really like Apple's vision for SwiftUI and they're catching up with missing features very quickly.