News for hackers. Stuff that matters.
Re:The State of SwiftUI by hombre_fatal on Monday September 14, 2020 @01:47PM (#24472959)
Building clients on other platforms makes you appreciate the freedom we have on the web.

Instead of waiting for Apple to fix SwiftUI, it's completely viable to bring your own abstractions, from React to Reason to Elm, to the web. And the cottage community that works on the most niche web abstraction is bigger than the Apple team allocated for SwiftUI.

It has its downsides, and sometimes we're all too eager to beat the drum of how bad the web can be, but it's also important to recognize the web as a fluke of history where we still have some control.

That said, I give Apple some credit for moving their own platform forward in a way that clearly borrows from what we've been doing with things like QML and React. I look forward to the day when my SwiftUI apps work well on both macOS and iOS. And it will be interesting if we reach a point where we don't need UIViewRepresentable because APIs like WKWebView have been adapted for the new declarative model.

Re:The State of SwiftUI by gumby on Monday September 14, 2020 @01:54PM (#24473049)
I agree with your overall point, but you don't need swiftui to develop for the mac/ios.
Re:The State of SwiftUI by dimitrios1 on Monday September 14, 2020 @01:55PM (#24473062)
I agree with your counterpoint, but you don't have many other desirable options.
Re:The State of SwiftUI by Wowfunhappy on Monday September 14, 2020 @02:01PM (#24473134)
I'm not really a developer myself, but I get the impression there's plenty of long-time Mac developers who like/enjoy making Cocoa apps with Objective-C and Swift, particularly in comparison to doing the same on Windows.

Outside of web-based technologies, what would you consider a "desirable option" for making UIs?

Re:The State of SwiftUI by anoncareer0212 on Monday September 14, 2020 @02:07PM (#24473185)
We do, but, it's mostly because we were raised on it and have a lot of ingroup memes for discrediting other options - my company forcing me to work outside iOS for the first time in several years was a real eye-opener.

I don't think Apple developers have the experience to see how far behind SwiftUI is and how little chance there is of them catching up, and I don't think non-Apple developers have the experience to see there's very little 'special' to ObjC or Swift.

Re:The State of SwiftUI by matthewmacleod on Monday September 14, 2020 @02:28PM (#24473422)
Hmm, I don’t recognise this characterisation. I have been a web front-end specialist for quite some time, and have also developed large-scale native UIs for both macOS and iOS. My perspective would be that there is no clear winner. The Apple environment is absolutely _miles_ ahead of the web platform in several respects; the web offers greater flexibility that comes with a corresponding cost.

I’d agree at least that platform-specific developers can often keep themselves far too isolated. They really should be making an effort to work cross-platform as much as possible, because learning about the different patterns and techniques used in different environments is an incredible force multiplier.

Re:The State of SwiftUI by pookieinc on Monday September 14, 2020 @02:43PM (#24473570)
As someone who is also a front end dev, can you share more? I’ve been getting into Swift development on my free nights, but between the horrendous Xcode IDE errors / lag and learning the ins and outs of a new strongly typed language, it makes me hug my vscode / js environment tighter to my chest
Re:The State of SwiftUI by anoncareer0212 on Monday September 14, 2020 @02:46PM (#24473610)
Maybe I'm conflating 'web framework' with 'anything that compiles down to JS'? It's impossible for me to think of areas where iOS dev felt miles ahead, but I can imagine if I was writing JS I'd feel that way (I'm really into Flutter lately)
Re:The State of SwiftUI by wayneftw on Monday September 14, 2020 @02:55PM (#24473735)
> The Apple environment is absolutely _miles_ ahead of the web platform in several respects...

Such as?

In any case, I'd assume those miles are only gained on iOS where Apple has gimped the newer web APIs.

Re:The State of SwiftUI by matthewmacleod on Monday September 14, 2020 @03:23PM (#24474039)
Such as?

Picking some features I like entirely at random: libdispatch, Core Data, comprehensive accessibility support, SpriteKit, Core Video, ARKit… basically, there are lot of powerful and reasonably consistent APIs (with good performance) that really make a bunch of development much more tractable. Some of these can be replicated on the web platform; others can't.

In any case, I'd assume those miles are only gained on iOS where Apple has gimped the newer web APIs.

I'm sure you appreciate why that kind of attitude is a bit silly and serves to demonstrate the exact effect I was initially talking about.

Re:The State of SwiftUI by anoncareer0212 on Monday September 14, 2020 @04:15PM (#24474599)
There's no way you think Apple is miles ahead on async programming and ORMs, the iOS community has been clamoring for replacements for both for years and there's _plenty_ of web libraries for both.

The rest looks like it's focused on graphics/stuff you wouldn't do on the web anyway - yes, the fact it's impossible on the web _means by definition Apple is miles ahead_, but claiming Apple is overall miles ahead on dev experience because of AR and video bitstream manipulation APIs is a bit blinkered, given very few developers get to use those APIs.

Re:The State of SwiftUI by rabenfrass on Monday September 14, 2020 @06:33PM (#24475908)
We’d like a swift version of Core Data (a graph of objects), not a ORM. For async programming we have GCD and reactive libraries, async await is on master already, a design document is expected this month.
Re:The State of SwiftUI by wayneftw on Tuesday September 15, 2020 @12:56PM (#24483514)
> Picking some features I like entirely at random: Yada1, Yada2, Yada3...

Those are not features. Those are names of developer libraries.

What do you think they can do that's so much better?

> I'm sure you appreciate why that kind of attitude is a bit silly...

Apple clearly nerfs the web on iOS and there's nothing silly about acknowledging that. It's actually kinda silly pretending that they don't xD

> and serves to demonstrate the exact effect I was initially talking about.

Hmm, that's not very clear at all. You said "platform-specific developers can often keep themselves far too isolated", but the web isn't "platform-specific" it's 100% cross-platform and that's why Apple hates it.

Re:The State of SwiftUI by millstone on Monday September 14, 2020 @03:31PM (#24474144)
Table views are the most striking example. Native table views were designed from the start to lazily load items, and so can trivially support very large lists.

The web has no APIs for this. Instead laziness is tacked on through JS, and invariably breaks find, scrolling, etc. Try scrolling to the bottom of your Chrome history: the scrollbar jumps and it's often not clear if/when you reach the bottom.

Re:The State of SwiftUI by anoncareer0212 on Monday September 14, 2020 @04:19PM (#24474650)
UITableView was a solved problem on the web by 2014 at the absolute latest.

iOS has scrollbar jumps unless you know the rendered height of every list item and the complete count of list items in advance (which is why Chrome jumps, it doesn't know the entire length of your web history, it's loading it in batches)

Funnily enough, _SwiftUI doesn't support lazy table views_. Seriously. It's nuts.

Re:The State of SwiftUI by millstone on Monday September 14, 2020 @05:47PM (#24475516)
Of course Chrome knows the length of your web history: it's a trivial SQLite call. They just can't display it naturally, because there are no browser-provided APIs for lazy tables.

I do not agree that the JS implementations have "solved" lazy tables: they're all invariably broken. For example if you hit cmd-A to Select All, Chrome history just selects what is faulted in. If you scroll down eventually you find unselected items. Safari doesn't have this problem and the main reason is its use of native tables instead of web tables.

I agree this is a big hole in SwiftUI as well. A lazy table requires cooperation between the framework and the app, which is an awkward fit for declarative UI frameworks like SwiftUI and the web.

Re:The State of SwiftUI by nmjenkins on Monday September 14, 2020 @10:42PM (#24477390)
While it's not built in, this is totally solvable in a performant way on the web. Fastmail's web UI lazy loads in mailbox lists of messages (which for some users can be 1,000,000+ items long). The scrollbar is correct and you can jump to an arbitrary point. You can select all. We've had this for, I dunno, 7+ years now?
Re:The State of SwiftUI by millstone on Tuesday September 15, 2020 @12:19AM (#24477841)
Fastmail is indeed a radical outlier on this front, by far the best of the bunch. Its lazy tables are still broken (Find and Print for example) but they get scrolling right, and that is significant.

It's not at all representative of the experience of using Gmail, Ymail, Hotmail. The web requires heroics to get quality.

Re:The State of SwiftUI by Razengan on Monday September 14, 2020 @06:25PM (#24475836)
Let's not forget accessibility. Apple seems to be the only major company who takes it seriously, and it shows.

macOS accessibility features alone have generally been light years ahead of Windows, for over a decade.

Re:The State of SwiftUI by kitsunesoba on Monday September 14, 2020 @07:04PM (#24476146)
Also, just having a standardized way to do a lot of things.

One such example is menus. Just about all Mac apps — even ported stuff using third party UI toolkits — hook into the standard menubar APIs, which means that every menu item of every app can have a key shortcut assigned (or reassigned) in System Preferences, even when the app's dev never bothered to add such configurability. Similarly, accessibility and scripting APIs can reliably grab the menu items of any app, improving automation and interoperability. One could probably even write a full replacement for the macOS global menubar without much fuss.

Compare this to Windows and Linux where it's quasi-normal for apps to implement menus their own way or eschew them altogether — there is no single way to grab menu items, just a ton of different possible ways, and if an app dev has decided to do their own thing you're just SoL.

Re:The State of SwiftUI by saagarjha on Monday September 14, 2020 @03:20PM (#24474003)
Accessibility? Consistency? Performance?
Re:The State of SwiftUI by cglong on Monday September 14, 2020 @02:30PM (#24473439)
I'd love to learn more. What technologies outside iOS have you used and what do they do better than SwiftUI?
Re:The State of SwiftUI by anoncareer0212 on Monday September 14, 2020 @02:44PM (#24473583)
React Native, Android Java, Android Kotlin, Flutter, Jetpack Compose

- Flutter is the runaway winner, in general

- ARC looks like a mistake in retrospect - you trade 'GC overhead' for memory leaks

- keeping autolayout _and_ absolute frames looks like a mistake: a significant portion of SwiftUI overhead is spent in autolayout

- after working with Swift and _loving_ it between Swift 1 and 4, seeing the issues and watching Apple staff up and get more rigorous to solve them, stapling SwiftUI right now is unconsciable

- it requires contorting the language spec and the slow speed removes the one benefit of all the other frameworks, hot reload on device.

- Apple seems confused because they can _enumerate tractable work that would improve SwiftUI_, but the sum of that work is large enough to place a real, performant, cross platform Swift UI O(years) out (c.f. Swift's stable ABI clusterfoo)

Re:The State of SwiftUI by mdgrech23 on Monday September 14, 2020 @02:46PM (#24473618)
I don't know much about SwiftUI but I'm surprised to hear it's far behind?
Re:The State of SwiftUI by kenver on Monday September 14, 2020 @07:20PM (#24476243)
At this point I actually prefer the cocoa methods of creating UI. This kind of tech also affects the architecture of the app that is utilising it - SwiftUI and the like seem to be quite prescriptive in terms of application structure, whereas with cocoa I feel that I have a lot more possibilities.
Re:The State of SwiftUI by Razengan on Monday September 14, 2020 @06:21PM (#24475819)
> but you don't have many other desirable options.

How did people make iOS/macOS apps before SwiftUI? i.e. before 2020?

Re:The State of SwiftUI by dimitrios1 on Tuesday September 15, 2020 @09:21AM (#24480876)
Apologies, the operative word was desirable. SwiftUI, at least in theory, has made the other options less desirable.
Re:The State of SwiftUI by grishka on Monday September 14, 2020 @10:17PM (#24477268)
So are you developing for the sake of the process or for the sake of the result? The result is always faster and lighter if you don't pile additional abstraction layers on top of whatever your platform offers (DOM for web and Cocoa/AppKit for macOS).
Re:The State of SwiftUI by hombre_fatal on Monday September 14, 2020 @02:09PM (#24473199)
But you need uikit/appkit. And if you aren't satisfied with those, your options to bring or build your own abstractions are very limited.
Re:The State of SwiftUI by charliemil4 on Monday September 14, 2020 @02:22PM (#24473359)
Maybe I’m weird, but I love UIKit/Autolayout and can’t stand web, with a slight distaste for SwiftUI.

The idea of frame hierarchy is much more concrete in the autolayout world - which I guess helps the most.

Re:The State of SwiftUI by jmull on Monday September 14, 2020 @02:36PM (#24473502)
> But you need uikit/appkit.

Or one of the various alternatives... Flutter, React Native, Cordova, maybe a few others. There are also game app engines for games and game-like apps).

There are definitely fewer decent alternatives than for the web, but you aren't exactly starved.

Also, the context here is bug fix release cycles... no matter what you choose there will be bugs and release cycles that don't always match what you want for your app.

Re:The State of SwiftUI by oscargrouch on Monday September 14, 2020 @02:25PM (#24473395)
I think its cool if you have this high-level abstractions that help in productivity as long as you have a 'fallback mode' to a more powerful api.

This is even true for script languages for instance. This is what make Javascript or Python more powerful than the language let them be. Being able to 'fallback' to C if things are not working the way they should.

Having SwiftUI or React are ok, if you can call imperative UIKit api's or web DOM when you need it.

Im very skeptic that this model will be feasible for the more "hardcore" cases of applications. So its important to have a powerful way to control things in details.

In hindsight, the modularity and the power that the web UI api gives you today is something to admire.

Its hard to have other examples where the bazar model ended up with better tools than the cathedral model. Especially if the cathedral model had time to do it later with the technological advantage only experience gives you.

Re:The State of SwiftUI by pjmlp on Tuesday September 15, 2020 @01:23AM (#24478119)
What freedom?

Developing GUIs in various form factors since the late 80's and I rather have a window context to draw whatever I need than faking menus with list items.

Project Houdini, WebGL + Web Assembly for the second coming of Flash alike tooling is thankfully already taking off.

Re:The State of SwiftUI by contextfree on Monday September 14, 2020 @02:46PM (#24473615)
How can this possibly be true? Web UI frameworks are built on top of the browser platform, and browsers are built on top of native desktop platforms, so aren't native desktop platforms inherently more flexible than web UI frameworks?
Re:The State of SwiftUI by redxdev on Monday September 14, 2020 @02:57PM (#24473761)
Browsers largely aren't taking advantage of native UI frameworks (aside maybe from the window chrome and basic controls). Aside from the minimum required to get an OpenGL context (or whatever graphics tech) onto the screen they don't need to build on native UI.

Sure, they're technically building on top of the native UI frameworks, but only by completely ignoring all of their functionality.

Re:The State of SwiftUI by fauigerzigerk on Monday September 14, 2020 @03:51PM (#24474330)
I am by no means an expert in graphics architectures so I'm sure someone will be able to explain this better and more correctly than I can. But as I understand it, "native" is itself a layered stack of APIs as you can see in this diagram:

https://developer.apple.com/library/archive/documentation/Co...

UIKit/AppKit is layered on top of Core Animation which is layered on top of Metal. Skia, the 2D graphics library that Chrome's rendering engine uses, is built on top of Metal (or at least transitioning to Metal from OpenGL on macOS).

So browsers have the same flexibility in principle as native UI toolkits and they are just as close to the metal. There is no inherent disadvantage. But flexibility is a double edged sword. It includes the ability to diverge from the platform look & feel. So that's where the debate has been raging on for decades.

In terms of performance I think any debate about optimisation of UI stacks pales in comparison to the question of where the data lives, who generates it, and how it gets to the CPU/GPU for processing and display.

Re:The State of SwiftUI by saagarjha on Monday September 14, 2020 @04:00PM (#24474452)
Saying that "both use Metal and have layers in between therefore they are largely at the same place" doesn't really work, because the abstraction layer that they expose is at a vastly different place and the internal pipeline for both is also very different.
Re:The State of SwiftUI by zepto on Monday September 14, 2020 @04:03PM (#24474480)
You are completely correct.

If people want to use web technologies on the desktop, there is Electron.

The converse is not true.

Re:The State of SwiftUI by johannes1234321 on Monday September 14, 2020 @07:32PM (#24476338)
The converse is webassembly+webgl. There are different cases where i.e. SDL-based games are being ported to "Web" also Qt provides WebAssmebly support.
Re:The State of SwiftUI by noahtallen on Monday September 14, 2020 @11:35PM (#24477648)
Right, but only for macOS. I imagine most Swift/SwiftUI development targets iOS, where web is really the only other target available.
Re:The State of SwiftUI by zepto on Tuesday September 15, 2020 @12:17PM (#24483020)
There’s nothing stopping you from using web technologies to develop iOS apps in exactly the same way.

Quite a few of the ‘cross platform’ toolkits work this way.

Re:The State of SwiftUI by pier25 on Tuesday September 15, 2020 @12:29AM (#24477883)
Can you run SwiftUI on Windows or Android?