Live data from Hacker News

SwiftUI Defaults Considered Harmful

tonsky.me

41–50 of 135 posts

Re: SwiftUI Defaults Considered Harmful

#41
post #31

Earlier quoted context omitted.

Yes.

That said, current iOS 13 adoption rate is already at 93%...

Yeah but it does mean that older devices become useless. For example, I have an iPhone 6 that I let my kid use, and he won't be able to run any of these new apps.

I also have an older Ipod touch, I was trying to find an audiobook player to use it to listen to books, I couldn't find any that was compatible.

Re: SwiftUI Defaults Considered Harmful

#43
post #38

This website's background color is considered harmful, and "considered harmful" essays are considered harmful.

After reading this I agree that SwiftUI terrible. I still don't get why it's considered "harmful" though.

This is basically a clickbait title at this point. After a now-famous CS letter by Dijkstra, "Go To Statement Considered Harmful"[1], the title format expanded dramatically. I'm personally a large fan of Meyer's '"Considered Harmful" Essays Considered Harmful'[2] as a explanation and satire of the genre. Wikipedia also has a decent summary[3].

1: https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.p... 2: https://meyerweb.com/eric/comment/chech.html 3: https://en.wikipedia.org/wiki/Considered_harmful

Re: SwiftUI Defaults Considered Harmful

#44

Earlier quoted context omitted.

My most popular app supports iOS 9, so it's not being rewritten anytime soon…

How many people are using iOS 9?

Very few, I’d expect, but for my target audience (students) I’d expect it to be biased a but more in that direction. It’s not a huge amount of extra work (just condition all the new code) so I’ve just keeping the requirements the same.

Re: SwiftUI Defaults Considered Harmful

#45
> Some things are probably just plain mistakes (very funny though). E.g. NavigationView takes its properties not from its constructor or via modifiers, but instead from the properties of its first child. WHY?

This sounds like it's just inheriting the default iOS behaviour? The current ViewController sets the Navigation View's properties.

I haven't touched SwiftUI yet, but I'd imagine the existing NavigationController setup still exists within the SwiftUI framework, and this weirdness exists due to legacy reasons essentially.

Re: SwiftUI Defaults Considered Harmful

#46
post #40

Reading through the syntax changes they made makes me really appreciate the decisions made around JSX and how that works, syntactically. It's just javascript , and none of these weird constructs need to be added into some DSL to support it. There's the reasonably minimal html-ish syntax, then "escape to javascript" to add in conditionals or loops or whatever. I wonder if there was (or still is) a way to do something…

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…

It's syntax sugar which does directly translate into JS though - you could actually just write the original/underlying code.

e.g.:

    
        
    
Becomes something like:

    React.createElement(Foo, { var: 'a' }, React.createElement(Bar))
It all boils down to

    React.createElement(component, props, ...children)
https://reactjs.org/docs/react-without-jsx.html

Re: SwiftUI Defaults Considered Harmful

#47
post #40

Reading through the syntax changes they made makes me really appreciate the decisions made around JSX and how that works, syntactically. It's just javascript , and none of these weird constructs need to be added into some DSL to support it. There's the reasonably minimal html-ish syntax, then "escape to javascript" to add in conditionals or loops or whatever. I wonder if there was (or still is) a way to do something…

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 you need 'logic', you just escape out to javascript with braces

    
      { isVerified ?  : null }
      madeofpalk
      
    
JSX has no conditional syntax, no ternaries or any extra constructs apart from how to nest children. This is I think a simplicity that would have been nicer to see in SwiftUI.

Re: SwiftUI Defaults Considered Harmful

#48

I'm in no hurry to start using SwiftUI. I'm giving it another year. That doesn't mean that I don't like it. I think it's a great idea. It's just having a hard time clambering out of the bassinet.

> It's just having a hard time clambering out of the bassinet

What are the reasons for you to have this opinion?

Re: SwiftUI Defaults Considered Harmful

#49

I tried out SwiftUI a couple of months ago and it was buggy even when sticking to the standard Navigation components.. But now it seems like a lot of problems have been solved https://stackoverflow.com/questions/59279176/navigationlink-...

Do you have more examples than just that single one?

I ask, because I've encountered a number of situations where I figured it's a bug, when in fact it was my lack of understanding this new framework.

Re: SwiftUI Defaults Considered Harmful

#50
post #21
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…

I agree for the most part however I have put a simple app in the store with it and it works fine, it's usable for small apps. I had to wrap a few UIKit elements and a few other workarounds that I can't think of right now. But overall I'm happy they released it early and can benefit from the communities feedback and usage rather than building the whole thing in secret and releasing something finished that we might not…

Yeah, my sentiments exactly. I'm in the process of finishing a small app for a client, and it's been a blast. As you said, a number of workarounds are necessary due to the fact that UIKit is so rich, and SwiftUI is rather sparse at the moment.

However the fact that it's so easy to build new UI components, at this phase partly makes up for it.

Post reply on HN