GUI development with Rust and GTK 4
91–100 of 172 posts
Re: GUI development with Rust and GTK 4
#92Earlier quoted context omitted.
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…
React is the most interesting GUI approach to me in this regard, as while you can use inheritance if you use the class-based component approach, functional components are, well, functions and can be built by rules of composition. I tend to do a lot of UI in the form of "component with a dozen parameters that almost nobody wants to use every day" that is wrapped by "specialization of the general component that has a f…
• They aren't really stateless because UI is full of implicit state. So the whole functional UI thing isn't really true. You just end up with odd alternative syntax for what would be object properties, but declared as magical local variables that retain their values across calls.
• No inheritance, interfaces or object identity means no way to write generic code! Want to write a function that locates every button in a UI and applies some behavior to it? Tough, you can't! (in react of course you can drop down to the DOM but in Compose there's no DOM to drop down to). I found this comes up a lot even in simple cases and is a serious limitation.
• "Design systems" (themes) are all custom widgets. There's not really any concept of an underlying widget toolkit with flexible visual styling. Combined with inability to write generic code, it means if you want to port to a different theme or customize anything beyond trivial aspects of the existing theme like font or colors, you have to actually rewrite your code.
• Composition for everything yields enormous amounts of boilerplate. You can't say "define a button that's the same as a regular button except with one additional aspect" and have it automatically stay up to date as the underlying button widget evolves. Instead you have to duplicate the entire API of the button and clone it into your own API, propagating the values by hand.
The annoying thing is that Kotlin already has some features for managing composition, but it requires you to use classes and interfaces. The "everything is a function" philosophy means you lose all those features. Composition also bloats up APIs because there's no longer any distinction between something that's relevant only to people customizing a control (i.e. a protected method) and something that's meant for the user of the control (i.e. a public method or property).
So I'm definitely feeling like sticking my neck out and defending OOP here. Probably there'll be a swing back towards OOP or a similar-but-rebranded form of it in future, as people realize that things like inheritance, subtyping etc were invented for valid reasons.
Re: GUI development with Rust and GTK 4
#93Earlier 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.
I had a quick look and it appears that the Linux backend is GTK-3 based? (Requires gtk-3-dev to build.) Pity. For a moment I was briefly excited that someone had created a Rust binding for EFL/Enlightenment (aka "E").
GTK is only required if you want the GTK WebView, iirc.
Re: GUI development with Rust and GTK 4
#94Some things seem a bit weird and ugly, and some idioms seem rather nice. Overall, not a clear win but certainly worth seeing the differences and similarities and thinking about them a little bit.
Re: GUI development with Rust and GTK 4
#95Earlier 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.
Agree with egui, although it is missing some widgets, they’re easy enough to build. But the real killer feature for me is that it’s cross platform including the web. Write once and compile to windows/Mac/Linux/web is finally here through Rust and egui.
Re: GUI development with Rust and GTK 4
#96Earlier quoted context omitted.
React is the most interesting GUI approach to me in this regard, as while you can use inheritance if you use the class-based component approach, functional components are, well, functions and can be built by rules of composition. I tend to do a lot of UI in the form of "component with a dozen parameters that almost nobody wants to use every day" that is wrapped by "specialization of the general component that has a f…
React type APIs (e.g. Jetpack Compose too) are interesting but actually I find myself wishing for OOP and inheritance back again. I'd probably quite like a combined approach. Raw functions calling each other have a bunch of weaknesses: • They aren't really stateless because UI is full of implicit state. So the whole functional UI thing isn't really true. You just end up with odd alternative syntax for what would be o…
Re: GUI development with Rust and GTK 4
#97AFAIK, 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…
For me the litmus test is if it has a fully-featured listview or treeview, so you can do something like a file browser, a library app, or other kinds of data-heavy apps. Also important is that keyboard and mouse work as expected (tabbing, shift-selection, etc). Bonus if it supports the current "native" OS paradigms. E.g. on Mac: transparent sidebar, integrated titlebar, on Windows: MS office 2022 style simplified too…
Re: GUI development with Rust and GTK 4
#98Earlier quoted context omitted.
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,…
Case in point: Blender has an outstanding GUI toolkit, non-native.
Re: GUI development with Rust and GTK 4
#99AFAIK, 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.