An unofficial, read-only Hacker News reader.

Declare is a UI language for you and your AI (opens external site)

127 points by ilamont 5 days ago | davidtemkin.github.io | 98 comments on HN

View full thread · View on Hacker News

Comment thread (11)

  1. I think Qt/QML really reached hit sweet spot for me when it comes to describing UIs (ignore if any syntax errors, doing this from memory):

    For eg. compare this:

    ``` Window { textColor: "slategray" property int v: 40

        ColumnLayout {
            id: layout
            anchors.fill: parent
            spacing: 20
    
            Text {
                id: number
                Layout.alignment: Qt.AlignHCenter
                font.pixelSize: 70
                text: v
            }
    
            ProgressBar {
                id: progressBar
                Layout.alignment: Qt.AlignHCenter
      
                value: v/100
                color: v < 50 ? "dodgerblue" : "turquoise"
            }
        }
    
        MouseArea {
            anchors.fill: parent
            onClick: v = (v+20)%100
        }
    } ```

    with Declare:

    ``` App [ textColor = slategray,

        group: View [ x = center, y = center, width = 80%,
            layout: SimpleLayout [ axis = y, spacing = 20 ],
    
            number: Text [ width = 100%, textAlign = center,
                fontSize = 70, fontWeight = bold, text = { "" + v } ],
    
            bar: Gauge [ width = 100%, value = { v },
                tint = { v < 50 ? cool : warm }, accessibilityLabel = "v" ],
    
            hint: Text [ width = 100%, textAlign = center,
                text = "click anywhere to change v" ]
            ],
    
        v: number = 40,
        cool: Color = dodgerblue,
        warm: Color = turquoise,
    
        onClick() { v = (v + 20) % 100 }
        ]
    
    ```
    Replies (6)
    1. QML was really something special. I’m sad that type of syntax never really caught on in the wider UI world.
      Replies (1)
      1. Yes. I love Qt/QML. Nothing has replaced it for me since. I find android/ios too hard to read, until Jetpack compose came along and even then. Dart is better
        Replies (1)
        1. It's so interesting how different frameworks appeal to different kinds of people. For me personally, I regret every second I've ever spent writing glue code. The whole signals/slots paradigm killed my desire to use Qt every time I tried it.
    2. Sad that it's similar slow and memory hungry like winui (qtwidget app use 10mb => qml 100mb).

      Additional to it it may have more fps, but feels less snappy.

      I still use it as it's better than electron, but still makes me sad.

      Replies (1)
      1. As good as QML / QtQuick is, I feel like it makes it very easy to create slower applications by creating too many objects, and too many property bindings.. A lot of QtQuick widget libraries made all kinds of mistakes and you end up really sluggish desktop applications.. even though - the fps counter shows 60 fps..

        But I have also seen really well optimized QtQuick applications that ran at 60 fps on a single core imx6 while playing video, applying all kinds of effects on the video...

    3. It lives on in Slint. The syntax is inspired to QML, but statically typed and compiled to native code (no JS engine, no browser). Can be used from different programming languages. https://github.com/slint-ui/slint
      Replies (1)
      1. I actually used to follow Slint back when we used Qt at $DAY_JOB! I learned quite a bit about compilers looking at your repo back then..
    4. Hm. Its great.

      I'm happy enough the with xml-based tsx - if only to differentiate between declared structure v.s. expressions.

      Especially (with what I've seen briefly) of Solid v2.

      But I'm sure I could get used to the above quick.

    5. Yeah I had a lot of fun building pretty stuff with QML. I always want to build my UI in it but never have a good fit.
    6. My thinking exactly https://ljos.dev/