Relm4: Idiomatic GTK Apps in Pure Rust
Relm4 makes developing beautiful cross-platform applications idiomatic
Relm4 is a Rust framework for building native, cross-platform GUI applications with GTK. It combines a declarative, Elm-inspired architecture with Rust's type system for robust, maintainable code. Relm4 supports async tasks, reusable components, and runs on Windows, macOS, and Linux without a runtime. Its comprehensive book and docs make it accessible for developers seeking a productive, idiomatic way to create beautiful desktop apps in Rust.
Using Rust's type system, Relm4 allows you to write robust and maintainable code.
- slacknatcher12
Reading the documentation, I just notice lots of familiarity with my own solution using haskell and gi-gtk4. I think that anybody that read https://bichanna.github.io/posts/tea-time/ will get the same ideas. This basically boils down to:
1. Use a native widget system such as GTK (I evaluated Qt too)
2. Wrap widgets into a component datatype that is aware on how to update the widget when the props/model changes.
3. Define a dispatch closure that is passed to widget that accepts messages. Actions on the widgets should use this instead of mutating a reference.
4. That dispatch closure is component aware and it will call the update function on all the widgets.
There are some extra complications for long running computations but the model is a good base to build on. I wish the best to the relm team, most likely I will use them when programminmg in rust.
- WD-42
I used plain gtk-rs for my last project and there is definitely some friction between rust and the gobject system. I think for my next project I will give relm4 a try. Apparently you can always drop back to gtk-rs if needed.
- pitched
This is Gnome/GTK, not cross-platform like I would have expected. A Linux-first approach. I’m happy that this is the world we’re in now but expect it still to be royal pain to get a build running on Windows. Huge congrats to everyone involved if not!
- Nekorosu
How does it help build idiomatic cross-platform apps? A cross-platform app can't really be idiomatic by definition, since different platforms have different idioms, both in terms of APIs and UI. If the project somehow solves this, I'd expect that to be explained. I couldn't find such an explanation on the website.
- chadcmulligan
Interesting - If you're after cross platform Flutter/Dart seems a more cross platform solution (mobile, desktop and web), or Delphi/Lazarus without the web.