This is actually a significant development for people who write GUI code in Rust. Finally we have a solid release of Rust bindings for GTK 4. In addition to that, the libhandy Rust bindings [1] allow for better development of Linux phone apps like for the PinePhone or the Librem 5, so an update to that crate is welcome too [2]. While GTK is not perfect, is is one of the few ways to write robust and usable GUI programs in Rust. Let us thank the developers for all the hard work that went into this release. The gtk-rs people work tirelessly and helped me out numerous times when I asked questions on IRC.
Have you built (or even used) anything that targets Mac OS or Windows using GTK bindings? How does the end result feel on those platforms, and how hairy is it to build?
Yes, I build for Windows but not Mac OS. You can actually cross-compile on Linux targeting Windows. That works well out of the box, I’ve tried it. You can also compile on Windows for Windows. That requires MSYS2 and a bit of configuration, but it’s not the end of the world (I avoid Visual Studio if possible and go with GNU tooling). The entire thing, along with build instructions, can be found here: https://github.com/BenjaminRi/Sherlog
As for the end result. My Windows users install the application with a Nullsoft installer which I generate with NSIS script. The installer puts all the files and dlls in the proper places. All the GUI elements behave as expected. It could look prettier. But it supports styles, so you can do a lot with styling to make it look good. Qt would probably look better, but the C++ bindings are an obstacle for Rust programmers. I don’t really care about looks, my application is a developer tool. For some elements, I had to implement my own manually rendered GUI elements on a plain canvas because I require insane performance that no GUI toolkit will deliver (not just GTK’s fault). You can get a lot out of GTK if you use it correctly, it can absolutely produce programs that are daily drivers. But it will never look exactly native. I use GTK because I want to support both Linux and Windows.
That looks much better on Windows than I expected it to. Certainly very serviceable for dev/admin tools. I like that the cross compiling works well out of the box. I’ve avoided exploring a GUI kit in any depth so far for Rust, but this clearly needs to go on the list for when that time comes.
I have built an application using GTK via gtk-rs. gtk-rs is really nice for writing applications is you are targeting X11 or Wayland. I am not a big GTK fan (I strongly prefer Qt), but gtk-rs makes writing GTK applications quite pleasant.
I also built the application for macOS and the result was… horrific? Rendering was awfully slow and there was virtually no platform integration, making the application stick out like a sore thumb.
Since most of the application logic was not in the GUI and there is no good support for Qt in Rust, we ended up rewriting the application in PyQt and using the main logic through PyO3 (Rust <-> Python bridge). This worked like a charm and the application felt near-native on macOS.
I’ve written a gtk3-rs app on macOS and it was “meh”. It is better integrated than an average Electron app or egui, but it’s still obviously not native. I’ve also run into some rendering performance problems on macOS that weren’t an issue on Elementary.
Can anybody here who has spent time with various Rust GUI bindings - has the dust settled yet and are we now to the point where significant GUI apps can now be built with them (and without issue)? I’ve been wanting to dive in, but am not sure of which library to adopt (as I’ve been waiting for years until something nice and stable comes along).
My only requirements are a) hassle free on Windows/OSX/Linux b) non-convoluted API that “just works”.
This is actually a significant development for people who write GUI code in Rust. Finally we have a solid release of Rust bindings for GTK 4. In addition to that, the libhandy Rust bindings [1] allow for better development of Linux phone apps like for the PinePhone or the Librem 5, so an update to that crate is welcome too [2]. While GTK is not perfect, is is one of the few ways to write robust and usable GUI programs in Rust. Let us thank the developers for all the hard work that went into this release. The gtk-rs people work tirelessly and helped me out numerous times when I asked questions on IRC.
[1] https://gitlab.gnome.org/World/Rust/libhandy-rs
[2] https://crates.io/crates/libhandy
Note that libhandy is for GTK3; the GTK4 equivalent is now libadwaita.
Have you built (or even used) anything that targets Mac OS or Windows using GTK bindings? How does the end result feel on those platforms, and how hairy is it to build?
Yes, I build for Windows but not Mac OS. You can actually cross-compile on Linux targeting Windows. That works well out of the box, I’ve tried it. You can also compile on Windows for Windows. That requires MSYS2 and a bit of configuration, but it’s not the end of the world (I avoid Visual Studio if possible and go with GNU tooling). The entire thing, along with build instructions, can be found here: https://github.com/BenjaminRi/Sherlog
As for the end result. My Windows users install the application with a Nullsoft installer which I generate with NSIS script. The installer puts all the files and dlls in the proper places. All the GUI elements behave as expected. It could look prettier. But it supports styles, so you can do a lot with styling to make it look good. Qt would probably look better, but the C++ bindings are an obstacle for Rust programmers. I don’t really care about looks, my application is a developer tool. For some elements, I had to implement my own manually rendered GUI elements on a plain canvas because I require insane performance that no GUI toolkit will deliver (not just GTK’s fault). You can get a lot out of GTK if you use it correctly, it can absolutely produce programs that are daily drivers. But it will never look exactly native. I use GTK because I want to support both Linux and Windows.
That looks much better on Windows than I expected it to. Certainly very serviceable for dev/admin tools. I like that the cross compiling works well out of the box. I’ve avoided exploring a GUI kit in any depth so far for Rust, but this clearly needs to go on the list for when that time comes.
(Note: not OP). I haven’t tried running Rust on Windows, but GTK itself is pretty easy to build and use on Windows, see e.g. https://www.collabora.com/news-and-blog/blog/2021/03/18/build-and-run-gtk-4-applications-with-visual-studio/ , https://www.collabora.com/news-and-blog/blog/2021/04/29/build-your-own-application-with-gtk4-as-a-meson-subproject/ (no affiliation, Collabora is just a big contributor on this side).
That being said, it’s very much the Gnome toolkit these days. It’s a pretty bad choice for cross-platform development.
In particular, note that GTK doesn’t implement accessibility (e.g. for blind people using screen readers) on Windows. Not sure about Mac.
I have built an application using GTK via gtk-rs. gtk-rs is really nice for writing applications is you are targeting X11 or Wayland. I am not a big GTK fan (I strongly prefer Qt), but gtk-rs makes writing GTK applications quite pleasant.
I also built the application for macOS and the result was… horrific? Rendering was awfully slow and there was virtually no platform integration, making the application stick out like a sore thumb.
Since most of the application logic was not in the GUI and there is no good support for Qt in Rust, we ended up rewriting the application in PyQt and using the main logic through PyO3 (Rust <-> Python bridge). This worked like a charm and the application felt near-native on macOS.
I’ve written a gtk3-rs app on macOS and it was “meh”. It is better integrated than an average Electron app or egui, but it’s still obviously not native. I’ve also run into some rendering performance problems on macOS that weren’t an issue on Elementary.
Can anybody here who has spent time with various Rust GUI bindings - has the dust settled yet and are we now to the point where significant GUI apps can now be built with them (and without issue)? I’ve been wanting to dive in, but am not sure of which library to adopt (as I’ve been waiting for years until something nice and stable comes along).
My only requirements are a) hassle free on Windows/OSX/Linux b) non-convoluted API that “just works”.