Hacker News new | past | comments | ask | show | jobs | submit login

Depends on what you mean by "clean". I'd say it's pretty good from what I can see? The examples are also incomparable; the one you link to is nearly 20 lines of code to define nothing more than an embedded triangle image and single text embed with a few colors, while the Swift example hosts an entire modal list with embedded picture components and text (while handling fluid scrolling, right-to-left langs, dark mode theming, etc all implicitly) -- all in the same number of lines or so (and had further mods made during the Keynote by a developer with similar brevity.) Judging from lines only or "cleanliness" I'd say SwiftUI is doing pretty good here, but ultimately the examples are too apples and oranges to draw any real conclusions from.

Syntax aside, there is a large semantic difference between the two: QML is a separate language/modeling tool that is embedded into the application runtime. SwiftUI is in fact ordinary Swift code and the UI you define with it is also ordinary Swift code too, code that XCode and the Swift compiler understand and analyze and refactor and compile like any other. Just with some special magic to make the UI builder work with it. I think this has a lot of advantages notably from a toolchain perspective, since you don't even need XCode (just the Swift compiler) to do things like xrefs/refactorings across SwiftUI code, nor maintain tooling like that across two languages (XYZ + whatever UI modeling language)

Given that, my first impressions of how far they took it (and how well it came out) are pretty good.




> while the Swift example hosts an entire modal list with embedded picture components and text (while handling fluid scrolling, right-to-left langs, dark mode theming, etc all implicitly)

I think you might check out more of QML / QtQuick 2 before drawing any conclusions.

    import QtQuick 2.12
    import QtQuick.Layouts 1.12

    ListView {
        model: Model.items
        delegate: RowLayout { 
            Image { source: image }
            Column {
                Text { text: title }
                Text {
                    text: subtitle
                    color: "gray"
                }
            }
        }
    }
This should be more or less the same. Fluid scrolling is backed by the underlying Flickable [1]. RTL support is available an can be changed in runtime [2]. Themes / colors can be changed in runtime as well [3].

Lastly, it runs on Windows, Linux and Android as well as OSX and iOS.

[1] https://doc.qt.io/qt-5/qml-qtquick-flickable.html

[2] https://doc.qt.io/qt-5/qtquick-positioning-righttoleft.html

[3] https://doc.qt.io/qt-5/qtquickcontrols2-styles.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: