Live data from Hacker News

GUI development with Rust and GTK 4

gtk-rs.org

61–70 of 172 posts

Re: GUI development with Rust and GTK 4

#61
post #40

At this rate programming languages will reinvent GUI builders from Delphi/Lazarus in 2050

I still find it quite sad that the pinnacle of GUI programming tools was reached over 20 years ago, when Delphi 6 was released, and we've been going more or less downhill ever since.

Honestly, all the momentum went to web UIs...desktop UI R&D then just died more or less.

Re: GUI development with Rust and GTK 4

#62

Earlier quoted context omitted.

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

I'm not sure what this has to do with the parent post or how it contradicts what I said. https://doc.rust-lang.org/std/keyword.static.html

You are referring to static variables which have ‘static lifetime. OP is asking about ‘static lifetime and whether GC would somehow collect garbage more precisely (it wouldn’t). You’re basically talking past each other.

Re: GUI development with Rust and GTK 4

#63
post #57

What about making it easy to import Rust business logic into C# / Swift / whatever GUI language you're using? I get the value of 100% (or 50% or 80%) implementing the UI in Rust; especially for tools that won't benefit from a native UI, or tools that only need light integration into platform-specific UI features. I've also shipped a desktop product that had a 100% native UI and a cross-platform codebase. Today, imple…

No experience with Rust, but for a couple of personal projects I’ve written the logic in Haskell and the GUI in C++ (e.g. https://github.com/bradrn/brassica/blob/master/ARCHITECTURE....). It works pretty well, at least for smaller projects — the basic idea is that the Haskell code gets compiled into a library (static on Windows, dynamic on Linux) which the C++ side can link to. I’d imagine doing the same with Rust would be even easier, since it’s less of a pain to marshal stuff across the language barrier.

Re: GUI development with Rust and GTK 4

#64
post #9

Rust GTK4 "hello world" app, as a downloadable project, demonstrating the builder pattern: https://github.com/SixArm/rust-guideposts/blob/main/projects...

Honestly this looks like programming style from 90s. Why not design UIs in an editor that saves layout to XML?

Machine generated XML doesn’t play nice with version control for views that are even moderately complex. Merge conflicts become more of a nightmare to untangle as your app matures, plus it can make pull requests unintelligible.

This is part of why for apple platform dev, several years ago I abandoned XML-based XIB and storyboard UI design for any collaborative project. Writing it all out in code (even with just UIKit, no SwiftUI) is a lot more pain-free.

I’d like to do the same for Android projects, but Google is hellbent on the XML usage if you’re building with Android Framework… Jetpack Compose improves the situation some but I’ve not used it much yet.

Re: GUI development with Rust and GTK 4

#65

Earlier quoted context omitted.

How would you get a static lifetime without a static object?

Unrelated to the above convo, but: An owned object can be bound by a static lifetime, for example. Eg, `fn foo (t: T){}\n foo(String::new());`

More dangerous / less common, but you can also launder lifetimes through unsafe where you use ‘static to indicate “it’s not possible to verify lifetime at compile time but I promise you this will outlive you”. An example of this would be storing a reference that is reference counted but you don’t want the lifetime to bleed out into the type signature.

Re: GUI development with Rust and GTK 4

#66
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.

Also, tableview/datagrid, complete with support for sorting and reordering items and columns. It’s shockingly difficult to find newer UI frameworks with this, even though it’s one of the most important desktop UI widgets for a lot of use cases. Win32, Cocoa, GTK, and Qt Widgets have it though, and that’s part of why those toolkits continue to get used.

Slint recently added a table widget complete with sorting, which was very welcome

Re: GUI development with Rust and GTK 4

#67

Earlier quoted context omitted.

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,…

> 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. As I alluded in my other comment, theming is possible but it's really limited if you expect anything close to what you'd typically expect. You can put borders and colors on frames, but it's pretty limited. For example, if you want to have a border with different…

I don't think I know what most people typically expect. I don't know what chrome is, and I'm all for flexibility, but short of some crazy winamp skins in the late 90s, I've never noticed anything being particularly more fancy than amiga500 widgets. Win95 added something. Osx added a bit more, but a box with a label that reverse highlights when I select it is really all I'm expecting.

I rarely create guis, mostly just cli tools. Is there a good intro to basic ui theory so I bdont upset people with higher expectations in the rare event I do create one?

Re: GUI development with Rust and GTK 4

#68

Earlier quoted context omitted.

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

How would you get a static lifetime without a static object?

Box::leak for one.

Re: GUI development with Rust and GTK 4

#69
post #9

Rust GTK4 "hello world" app, as a downloadable project, demonstrating the builder pattern: https://github.com/SixArm/rust-guideposts/blob/main/projects...

Honestly this looks like programming style from 90s. Why not design UIs in an editor that saves layout to XML?

In a project with many developers, it's hard to resolve conflicts with generated XML. For example, iOS and Android have been moving towards a declarative approach with Swift UI / Compose.

Re: GUI development with Rust and GTK 4

#70

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

‘static is a compile time thing for ensuring memory safety. It doesn’t really have anything to say about when the object will be collected. In fact, since Rust/C/C++ applications use precise garbage collection techniques, they’re going to track the lifetime strictly more accurately than a garbage collected language (which I’m presuming you mean tracing GC). Of course you could have a memory leak / reference cycles but memory leaks are possible with tracing GCs as well (just different kinds of leaks but they are a strict subset of the situations that would cause a leak for things like reference counting iirc).

What lifetimes do let you accomplish is more fearless ownership tracking and letting the compiler expire references for you without needing to use any kind of reference counting. And all things being equal, precise garbage tracking results in lower peak and average memory usage.

Post reply on HN