Live data from Hacker News

SwiftUI Defaults Considered Harmful

tonsky.me

81–90 of 135 posts

Re: SwiftUI Defaults Considered Harmful

#81
post #73

I was really excited about SwiftUI after having done a lot of React development recently. The declarative style is so much nicer than the MVC/procedural code that regular UIKit code becomes. After 30 minutes of updating Xcode I was able to start writing SwiftUI code. Then another 2 hours upgrading our Swift project to the latest version of Swift. I googled for documentation, found barely anything and the code samples…

I suspect Apple knows the developer experience for Swift is terrible (even if the Apple developer community at large is in mass denial about this). The number 2 item on Swift Core Teams goals for Swift 6 is "Create a fantastic development experience". See: https://forums.swift.org/t/on-the-road-to-swift-6/32862 Whether anyone at Apple cares about documentation any more is another matter. A really sad state of affairs…

I don't know, maybe some of the die hards are in denial. I really enjoy the language and the platforms but I'd readily admit it's pretty far behind in terms of DX. I think at this point Apple is going to have to make this a really big priority if they want to remain relevant and it's going to take a lot of effort on their part.

Re: SwiftUI Defaults Considered Harmful

#83
> I mean, the only difference before the two is whether you have to put a comma between elements or not.

Personally, I vastly prefer minimizing punctuation in code. Most punctuation like this only lends itself to creating places where additional errors and bugs can creep in. Listing elements on separate lines gives you the separation needed so it's clear it's a list of things, the comma at the end of the line is needless.

> All because someone in charge of API design was afraid of lists and had more power than someone in charge of Swift language.

I suspect the people in charge of designing the Swift language have a similar aversion to needless punctuation in the language. They made a point of calling out the lack of a semi-colon in the original Swift launch announcement. This isn't some API designer pushing the issue, it's part of the philosophy of the language.

Re: SwiftUI Defaults Considered Harmful

#84

Honestly, just use UIKit. SwiftUI is a bolt-on framework on top of UIKit to provide a React-like experience for web devs so they won’t rage too much when Apple inevitably bans ReactNative and Flutter.

SwiftUI is raising the abstraction layer and aiming to provide something much more productive than what UIKit currently offers. You've framed your comment as if web developers are cargo-culters who only know how to use React. The web has already experimented with classic MVC approaches (backbone etc.) and moved beyond it. Android's Compose is taking a similar approach, as is Flutter which as far as I can tell is not necessarily aimed at web developers. Also why would Apple ban React Native and Flutter?

Re: SwiftUI Defaults Considered Harmful

#85
post #16

There are definitely a few things it does that are weird, and this article hits on a few of them. But, I'll call special attention to the whole "adaptive padding thing" as a broader signal for something I feel that SwiftUI does very, very right and more UI frameworks need to start thinking about. Its made to design iOS apps. iOS has a design language that (1) is relatively consistent, (2) changes over time, and (3) c…

Haven't we been going in the other direction in recent years? With integrated title bars in browsers, custom css, fonts etc.. Chrome on Windows, Mac, Linux etc. always looks like chrome but not native. Similarly webpages look "exactly like the designer intended" even if it is a very bad fit for your device. We used to do things generically, but changed to prescribing every little detail and this now breaks when our a…

Case in point: WhatsApp TestFlight betas recently gained support for dark mode, because they decided to do custom UI (and, honestly, not a terrible one) and it took ages for them to fix it up to support dark mode.

Meanwhile, many native-iOS developers had dark mode support on day one, because they stuck closer to iOS conventions and didn't do as much custom UI.

Re: SwiftUI Defaults Considered Harmful

#86
post #40

Earlier quoted context omitted.

Surely JSX is ... well it's something that looks a lot like XML, hence the name. It's not just JavaScript, is it? It's pretty much the definition of embedding a DSL. I've not used SwiftUI but I've used TornadoFX which is similar, but with Kotlin instead of Swift. There's no weird syntax or DSLs (even though they call it that). It's all just functions and lambdas, so the language is always there and the syntax is alwa…

JSX is 'just' an XML-like syntactic sugar for making nesting function calls nicer in Javascript. Yes, its a DSL, but it keeps the "domain" extremely small and it transpiles in a very straightforward way down plain javascript madeofpalk // is syntactic sugar for React.createElement(Container, null, React.createElement(Text, { weight: "bold" }, "madeofpalk"), React.createElement(Image, { src: profilePic }) ); Whenever…

Interesting that in PHP days, mixing logic and markup was taboo, and now it's all the rage.

Re: SwiftUI Defaults Considered Harmful

#87

Earlier quoted context omitted.

JSX is 'just' an XML-like syntactic sugar for making nesting function calls nicer in Javascript. Yes, its a DSL, but it keeps the "domain" extremely small and it transpiles in a very straightforward way down plain javascript madeofpalk // is syntactic sugar for React.createElement(Container, null, React.createElement(Text, { weight: "bold" }, "madeofpalk"), React.createElement(Image, { src: profilePic }) ); Whenever…

Interesting that in PHP days, mixing logic and markup was taboo, and now it's all the rage.

Very specifically, this is not mixing "logic and markup" in the way that was taboo.

This is all UI logic. Should a button be displayed or not. How large should this rectangle be. React encourages you to place that logic close to where it's used so it's easier to understand.

The line React devs has used is when people look at JSX and shout "separation of concerns", what they're really grasping at is "separation of languages".

Re: SwiftUI Defaults Considered Harmful

#88

> When fixing broken layout, it is always easier to add stuff that you forgot than removing stuff that your framework did for you and you that can’t see. This paragraph reminded me of this old Jargon File koan: --- In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6. “What are you doing?” , asked Minsky. “I am training a randomly wired neural net to play Tic-Tac-Toe” Sussman…

I've never understood this one. Initialized randomly and then trained is accurate; Minsky is the one who comes off as ignorant, when the last line is supposed to indicate the opposite.

Re: SwiftUI Defaults Considered Harmful

#89

Earlier quoted context omitted.

> It's just having a hard time clambering out of the bassinet What are the reasons for you to have this opinion?

Mostly the limited uptake (I anticipated that), and the maturity of the tools. I despise IB/Storyboard Editor, but it gives some serious control over a lot of stuff. I don’t mind doing programmatic tweaking, but on my machine, at least, I don’t get very reliable previewing. I have to run the app to get an idea of how my tweaks are working (to be fair, IBE is similar, but the preview is somewhat more reliable). I real…

Limited uptake by developers you mean? How do you determine that?

I had two instances where the preview turned out to be a hassle (crashing, or hard to get it to work).

First was a test project with Core Data. It was a hassle to set up the preview. So much so, that I often skipped it.

Second instance was crashing; I'd created a View but the layout was based on something in UserDefaults, and I forgot about that. So when I created another view that incorporated that first view, I got crashes. So bad, in fact, that a restart of Xcode didn't help. I had to close Xcode, then on the commandline, find and kill the daemon responsible for previews.

Were you able to point to causes of the unreliable previewing in your case?

Re: SwiftUI Defaults Considered Harmful

#90
post #18

Observing the launch of SwiftUI as a bystander (I'm not developing for any Apple platform), it seems that people are very excited about SwiftUI, but also get burned by it a lot. This is mostly Apple's fault by releasing this framework without any caveats. But the framework is more like an early alpha, not to be used in production. Tooling is not yet ready, documentation is not yet ready, heck even Swift –the language…

You are not developing for any Apple platform. And then later you state that the framework is more like an early alpha, not to be used in production.

On what basis do you make that rather bold statement?

Post reply on HN