Remix.run Logo
▲ thisismyanon2 19 hours ago

My experience has been that DSLs don't scale well. For simple things they provide a veneer of ease-of-use but eventually they were an albatross with Chef just as they were with QML and Slint. With both Slint and various Qt bindings for Rust marshalling data between Rust and the UI is painful. With Slint you get the added bonus of things just not yet existing in the DSL. That's a result of both immaturity and a strong focus on mobile at the expense of desktop. But the result is same. gpui has a killer dock widget, QML has the primitives to approximate one, and it's pretty much a no-go with Slint (though there's a third-party dock widget for Slint it's written in C++).

Here's a more idiomatic version of the previous example. IME gpui (and iced) is a lot easier to extend than something with a DSL, and if you check out the gpui example you'll see that gpui provides convenient methods to get consistent styles vs the Slint example where you hardcode widths and sizes. Those hex color abbreviations give me a facial tic every single time.

    use gpui::{black,red,green,blue,yellow,white};

    let Self{text,..} = self;
    
    v_flex()
        .gap_3()
        .bg(rgb(0x505050))
        .size(px(500.0))
        .justify_center()
        .items_center()
        .shadow_lg()
        .border_1()
        .border_color(black())
        .text_xl()
        .text_color(white())
        .child(format!("Hello, {text}!"))
        .child(
            h_flex()
                .gap_2()
                .children(
                    [red(), green(), blue(), yellow(), black(), white()].map(|color|
                        div().size_8().bg(color)
                    )))