Live data from Hacker News

GUI development with Rust and GTK 4

gtk-rs.org

21–30 of 172 posts

Re: GUI development with Rust and GTK 4

#21
post #4

AFAIK, for better or worse, this is the only UI crate (other than HTML-like UI using something like Tauri) that provides a full set of widgets/capabilities on Rust. Every other UI lib is incomplete in some way or falls short for anything other than a toy or specialty type app in my experience. UPDATE: Things I have my eye on as they mature: Slint, egui, and iced. I'm especially watching iced as Pop_os is using it for…

I would add the following to your list: - Vizia https://github.com/vizia/vizia - Freya https://github.com/marc2332/freya - Xilem https://github.com/linebender/xilem - Floem https://github.com/lapce/floem

I'm aware of those, but I don't consider those UI crates in the same way as gtk-rs. The best analogy I can come up with is I don't consider react or vue-js UI libraries either, but low level libraries that can be used to build a UI lib. I consider Material UI (which uses react) to be a UI lib, for example. In the same way, AFAIK these crates are much more concerned with inventing the best UI paradigm than they are at having a full set of widgets useful in creating business apps.

TLDR; I think of these as low level crates, not high level UI crates. If that changes, they will be added to my watch list.

Re: GUI development with Rust and GTK 4

#22
I wondered how Rust would tackle the problem of creating a GUI without C++/Java style inheritance and now I see the answer: you must explicitly compose all "inherited" traits in your subclass. "Unfortunately, nobody found yet a good way to do that. Which is why, as of today, subclassing of GObjects in Rust requires to mention all ancestors and interfaces ..."

Re: GUI development with Rust and GTK 4

#23

What are the disadvantages of using 'static here? I wonder if a garbage collected language would have a more accurate life time for that object

You wonder based on what? Static will put something in the binary itself and it will be memory mapped in, which won't even need to be directly allocated.

The apostrophe isn’t superfluous. ‘Static in this context refers to static lifetime. Lifetimes have absolutely 0 impact on runtime.

Re: GUI development with Rust and GTK 4

#24
post #4

AFAIK, for better or worse, this is the only UI crate (other than HTML-like UI using something like Tauri) that provides a full set of widgets/capabilities on Rust. Every other UI lib is incomplete in some way or falls short for anything other than a toy or specialty type app in my experience. UPDATE: Things I have my eye on as they mature: Slint, egui, and iced. I'm especially watching iced as Pop_os is using it for…

I think egui is complete enough to use in real apps. Layout can be a bit weird, but I haven't found anything that's impossible. I might even prefer it for cross-platform apps since startup time is so slow for GTK on Windows.

I use egui for my emulator and it is really good. It's very stable and small enough that you can find your way in without too much searching it. Its speed is pretty fast (I have to render things at under 1/50s).

For me egui, is totally mature as long as you don't need too much. The fun factor induced by the immediate mode and the GL rendering speeds are definitely a plus !

Re: GUI development with Rust and GTK 4

#25
post #4

AFAIK, for better or worse, this is the only UI crate (other than HTML-like UI using something like Tauri) that provides a full set of widgets/capabilities on Rust. Every other UI lib is incomplete in some way or falls short for anything other than a toy or specialty type app in my experience. UPDATE: Things I have my eye on as they mature: Slint, egui, and iced. I'm especially watching iced as Pop_os is using it for…

Thanks for this summary. It’s one thing that’s kept me away from rust and also webassembly in a similar way.

Re: GUI development with Rust and GTK 4

#26
post #19
post #10

Earlier quoted context omitted.

While you can create one on your own, any lib that doesn't have a tree widget isn't ready for primetime IMO. Obviously others may have a different opinion. Also, I don't believe there is any way to embed a webview at this point which is often necessary to embed things like charts or other widgets you don't want to create on your own.

GUI toolkits are like MS Word... as the saying goes, everybody only uses 10% but everyone uses a different 10%. This is one of the major things that makes it so hard to have a truly world-class widget set. Making "a" widget set is easy. Making a great one is staggeringly enormous.

I agree - which is why it seems like a better idea to either write bindings to an existing one or use something like Tauri/flutter/etc. It will be VERY hard to both 1) create an adequate UI paradigm in Rust -AND- 2) have a complete widget set large enough to create any business app

Re: GUI development with Rust and GTK 4

#27

I wondered how Rust would tackle the problem of creating a GUI without C++/Java style inheritance and now I see the answer: you must explicitly compose all "inherited" traits in your subclass. "Unfortunately, nobody found yet a good way to do that. Which is why, as of today, subclassing of GObjects in Rust requires to mention all ancestors and interfaces ..."

You can create UIs entirely out of composition. It's not even that hard, or that foreign per se. The problem you see there is a mismatch between Rust and GTK specifically, not GUIs in general. Of course, all the major GUIs are inheritance based, but I count that as less evidence than I might under other circumstances because GUI toolkits are multi-decade endeavors at the top end, and all the viable ones date to when inheritance was still the Law of the Land.

Re: GUI development with Rust and GTK 4

#28
post #14

Earlier quoted context omitted.

I think egui is complete enough to use in real apps. Layout can be a bit weird, but I haven't found anything that's impossible. I might even prefer it for cross-platform apps since startup time is so slow for GTK on Windows.

The challenge with egui is the theme. It looks ok, but isn't good enough for a commercial business app for example. Also, I believe it lacks a webview, so if you are in a pinch the only thing you can do is create your own widgets without a way to cheat and embed some web content. I would agree for certain types of apps it may be "good enough" (science, gaming, medical perhaps...anything where the UI is secondary to t…

Native look and feel is vastly overrated imo. Delphi and before it borland builder made for great UIs despite not looking native. To the point that when I came across that widget set, I knew I was in for a good UX. Still many bespoke interfaces, like at a brakes repair or small lumber yard chain use delphi and it works just fine.

As for the webview, thats a thing, but if you will have web access, you can target wasm, and make the egui interface embedded in the webpage instead of the other way round. But yeah, I don't see a webview being part of eframe/egui proper anytime soon because it treats wasm as a tier one target. You might see it supported third party the same way the efile crate supports open file dialogs but only for windows or linux builds.

Edit: dropping the demo link here for people to poke around. I'm curious what people use that is missing, and what people find unsuited to commercial use.

https://www.egui.rs/#Demo

Re: GUI development with Rust and GTK 4

#29
post #4

AFAIK, for better or worse, this is the only UI crate (other than HTML-like UI using something like Tauri) that provides a full set of widgets/capabilities on Rust. Every other UI lib is incomplete in some way or falls short for anything other than a toy or specialty type app in my experience. UPDATE: Things I have my eye on as they mature: Slint, egui, and iced. I'm especially watching iced as Pop_os is using it for…

I have not looked, but are there no Qt bindings for rust? Qt is about as complete as they get.

- https://github.com/woboq/qmetaobject-rs

- https://github.com/KDAB/cxx-qt/

Re: GUI development with Rust and GTK 4

#30

What are the disadvantages of using 'static here? I wonder if a garbage collected language would have a more accurate life time for that object

You wonder based on what? Static will put something in the binary itself and it will be memory mapped in, which won't even need to be directly allocated.

'static is a lifetime here.
Post reply on HN