Live data from Hacker News

A Proposal for an asynchronous Rust GUI framework

notgull.github.io

31–40 of 59 posts

Re: A Proposal for an asynchronous Rust GUI framework

#31
post #29
post #16

Earlier quoted context omitted.

> I think a bigger issue is that Rust just isn't a good language to write a game engine or a UI in. Here's my hot take of the day, as a Rust dev/fan/proponent who's done a few different GUI projects in the language: it's actually mostly fine , but Rust developers won't just settle for "just make it work". There is true value in a cross-platform common wrapper of native widgets that nobody is really hitting. So many o…

At that point, why Rust? Like, ARC has a much higher overhead than a good GC.

There are a litany of benefits to Rust that include, but are not limited to:

- Cargo and the general ecosystem

- The relative ease of integrating with just about any other system

- The ability to just build a binary rather than dealing with bundling interpreted languages (like with general Python/Ruby/JS/etc)

See my other comment in this thread for why I consider that "higher overhead" to be meaningless for general applications.

Re: A Proposal for an asynchronous Rust GUI framework

#32
post #29
post #16

Earlier quoted context omitted.

> I think a bigger issue is that Rust just isn't a good language to write a game engine or a UI in. Here's my hot take of the day, as a Rust dev/fan/proponent who's done a few different GUI projects in the language: it's actually mostly fine , but Rust developers won't just settle for "just make it work". There is true value in a cross-platform common wrapper of native widgets that nobody is really hitting. So many o…

At that point, why Rust? Like, ARC has a much higher overhead than a good GC.

It depends on the use-case. Also with Rust, unlike Swift for instance, you only put behind an Arc what needs to be, whereas in a managed language you pay the GC overhead for the entirety of your objects.

Re: A Proposal for an asynchronous Rust GUI framework

#33
post #30

Earlier quoted context omitted.

> Arc/Rc the hell out of it... Ooof, and now were back to what's a fundamental problem in a lot of "traditional" C++ game code bases I've seen (including my own stuff I wrote in the late 90's to early 2010's). Refcounting overhead cannot be ignored when performance matters, and since refcounting usually 'infects' the entire code base, it's impossible to fix once it becomes a performance problem - because then it's to…

> what's a fundamental problem in a lot of "traditional" C++ game code bases I'll be more clear that I consider the needs of games and the needs of general apps to be very different, and I am particularly discussing the latter and not the former. > Refcounting overhead cannot be ignored when performance matters, People throw around the meme of "performance matters" in the GUI space when we've had mostly working solut…

If you treat every UI widget as its own refcounted object (or even multiple), maybe even uniquely heap-allocated, arranged in deep hierarchies, and share references to those objects within and outside the UI code, then the situation isn't much different from a typical OOP game code base (just replace "UI widget" with "game object")

The most important 'technical quality' of both application types is that user interaction latency must be low, and everything animates smoothly with the display refresh rate without hickups.

Refcounting overhead isn't much of a problem if the number of refcounted objects is in the low hundreds or low thousands (e.g. a simple game or UI application), but it will become one with tens- or hundreds-of-thousands of refcounted objects which are frequently created, destroyed or "shared" (and with a naive approach those numbers are easily in reach as soon as UI table views come into play) - one typical problem for instance is destroying an object at the root of a large dependency tree, which then may 'ripple outward' and cause the destruction of thousands of other objects, causing noticeable hickups (not much different from garbage collection spikes).

Re: A Proposal for an asynchronous Rust GUI framework

#35
post #29

Earlier quoted context omitted.

At that point, why Rust? Like, ARC has a much higher overhead than a good GC.

It depends on the use-case. Also with Rust, unlike Swift for instance, you only put behind an Arc what needs to be, whereas in a managed language you pay the GC overhead for the entirety of your objects.

ObjC's and Swift's ARC (Automatic Reference Counting) is not just dumb "reference-count everything", the compiler does static lifetime analysis and removes redundant refcounting operations.

In theory at least this may actually yield better results than in C++ and Rust where refcounting is implemented as stdlib feature and optimizations rely on "zero cost abstractions" late in the compilation process.

But even ARC needs a lot of handholding and manual tweaking if performance matters.

Re: A Proposal for an asynchronous Rust GUI framework

#36
post #3
post #2

> Here’s one of this year’s dozen new Rust GUIs. Right. On the game engine side, there's the comment that Rust has 50 game engines and 5 games. A new GUI framework might not be what's needed. I'd like to see some of the most used ones get finished . I'm waiting for the six-month WGPU overhaul to finish to unblock the Rend3 overhaul so I can use a newer version of egui. Egui botches layout if there's a line wrap in a…

I think a bigger issue is that Rust just isn't a good language to write a game engine or a UI in. I wrote a toy game engine in Rust and quickly learned it basically sucks. The entire reason games and UIs exist is to mutate state in weird, complex, and often circular, ways. Rust's borrow checker doesn't lend itself well to this problem.

I would disagree with this.

Some points:

- UI frameworks and Game Engine tends to be huge when completed to a point where they are an easy choice for anything beyond some fun projects. The _huge_ majority of them have organizations/money backing in some form, through sometimes implicit. So the huge majority of open source versions of them no matter which language they are in will never be competitive.

- the state of established UI frameworks is kinda a mess, the divergence between the research world and what is practically used is in most places quite often humongous (e.g. what the blog post describes is conceptually a version of using continuations for GUI libraries and state handling in them, something well established as "a grate idea, if you can make it work nicely with the limitation of widely used programming languages" in computer since since I think 10+ years or so), and it's pretty common that patterns people are used to (e.g. inheritance for code reuse) are actually anti-patterns which kinda somewhat happens to be usable in that case but have serious issues you IMHO often don't notice until using them in larger projects (as in many people working on the software in parallel) where it's then often blamed on other things

- due the the mess the state handling in GUIs often ends up in it tends to profit from using a GC and the using borrows only in rust will likely fail. But then given the perf-characteristics and what tends to be a hot paths of GUIs _you really don't need to write borrows only code_, using an Rc/Arc and similar tends to be perfectly fine, i.e. the issue is in my experience more people obsessing over micro optimizations for that context

- on the other hand for game engine you often want to avoid GC for the engine/core parts themself (i.e. not dialog script and similar) and in general have a much stricter state handling using stuff like a ECS, there is no reason for rust to not handle that well. Through writing the ECS library might involve usafe code, due to it involving writing fundamental data structures. Most importantly in recent years "memory safety" of C++ has become an increasingly bigger issues for AAA-games, especially for multiplayer games where there is a risk of a hacking the users computer through the game client, and the money spend on combating that issue is non trivial to a point that you probably should avoid most code which conceptually works in C++ but couldn't work in rust due to the borrow checker (assuming you already have a well done ECS library with the right soundly implemented data structures).

- similar to writing fundamental data structures, writing a game engine proper is really really hard but seems simple as long as it's only a "toy", rust isn't good at that, sure. But also there is limited value at being good at writing throw away toys which can't be used in any production context IMHO. What does matter is if you can have a nicely usable production ready _maintainable_ game engine in rust, and AFIK yes you can somewhat already have.

Re: A Proposal for an asynchronous Rust GUI framework

#37
post #30

Earlier quoted context omitted.

> what's a fundamental problem in a lot of "traditional" C++ game code bases I'll be more clear that I consider the needs of games and the needs of general apps to be very different, and I am particularly discussing the latter and not the former. > Refcounting overhead cannot be ignored when performance matters, People throw around the meme of "performance matters" in the GUI space when we've had mostly working solut…

If you treat every UI widget as its own refcounted object (or even multiple), maybe even uniquely heap-allocated, arranged in deep hierarchies, and share references to those objects within and outside the UI code, then the situation isn't much different from a typical OOP game code base (just replace "UI widget" with "game object") The most important 'technical quality' of both application types is that user interact…

> but it will become one with tens- or hundreds-of-thousands of refcounted objects which are frequently created and destroyed (and with a naive approach those numbers are easily in reach as soon as table views come into play)

Look, I'm sorry but it's just bananas to throw around "hundreds of thousands of refcounted objects" when I've already bluntly pointed out that I'm discussing general application building. Joe Schmoe wanting to put together an email client should be able to slap a column view somewhere that can render a virtualized list and move on with their life.

This has been fine in multiple different native widget kits for some time now. It is not as intensive as what some games want to do UI-wise. The current situation does lead to overly complex UI approaches and contributes to the general approach of "smack it with a web browser" that we all collectively bemoan.

Re: A Proposal for an asynchronous Rust GUI framework

#38

Earlier quoted context omitted.

It depends on the use-case. Also with Rust, unlike Swift for instance, you only put behind an Arc what needs to be, whereas in a managed language you pay the GC overhead for the entirety of your objects.

ObjC's and Swift's ARC (Automatic Reference Counting) is not just dumb "reference-count everything", the compiler does static lifetime analysis and removes redundant refcounting operations. In theory at least this may actually yield better results than in C++ and Rust where refcounting is implemented as stdlib feature and optimizations rely on "zero cost abstractions" late in the compilation process. But even ARC nee…

Granted, it probably has improved a lot since 2016, but I didn't have an occasion to update my knowledge about Swift since then. Back then you definitely ended up with tons of pointless ARCs, but in fairness the compiler was brand new at that point so no wonder it wasn't good at optimizing stuff away.

Re: A Proposal for an asynchronous Rust GUI framework

#39
post #16

Earlier quoted context omitted.

> I think a bigger issue is that Rust just isn't a good language to write a game engine or a UI in. Here's my hot take of the day, as a Rust dev/fan/proponent who's done a few different GUI projects in the language: it's actually mostly fine , but Rust developers won't just settle for "just make it work". There is true value in a cross-platform common wrapper of native widgets that nobody is really hitting. So many o…

> Arc/Rc the hell out of it... Ooof, and now were back to what's a fundamental problem in a lot of "traditional" C++ game code bases I've seen (including my own stuff I wrote in the late 90's to early 2010's). Refcounting overhead cannot be ignored when performance matters, and since refcounting usually 'infects' the entire code base, it's impossible to fix once it becomes a performance problem - because then it's to…

yes, except thats why you use stuff like ECS systems

which involve fundamental data structures so writing them might involve unsafe rust code

but using them doesn't and they work as well in rust as outside

similar resource/allocation pools in combination with handles into them are a common practice to improve performance, and they work well in rust too (through like e.g. an ECS they often are unsafe to write but safe to use)

So while I would agree that "Arc the hell out" doesn't work for game engines (but IMHO does work for GUIs), I also would argue that if you use common patterns you anyway might have used anyway for better performance, complexity handling and/or reduction of the consequences of buggy code (e.g. prevent crashes) you don't have a problem with using rust.

Through I guess that makes writing "toy" games where you normally wouldn't bother with such patterns a much less nice experience to write in rust.

Re: A Proposal for an asynchronous Rust GUI framework

#40
post #30

Earlier quoted context omitted.

> Arc/Rc the hell out of it... Ooof, and now were back to what's a fundamental problem in a lot of "traditional" C++ game code bases I've seen (including my own stuff I wrote in the late 90's to early 2010's). Refcounting overhead cannot be ignored when performance matters, and since refcounting usually 'infects' the entire code base, it's impossible to fix once it becomes a performance problem - because then it's to…

> what's a fundamental problem in a lot of "traditional" C++ game code bases I'll be more clear that I consider the needs of games and the needs of general apps to be very different, and I am particularly discussing the latter and not the former. > Refcounting overhead cannot be ignored when performance matters, People throw around the meme of "performance matters" in the GUI space when we've had mostly working solut…

I agree refcounting is fine in state in a GUI, i.e. for using the GUI framework. But IMHO it's not fine for in state in many games.

It might also be less fine so for writing a GUI framework/library.

But it doesn't need to be IMHO as for writing the framework/library you can put your hand in the box of fancy data structures and use what's best suited even if it's implementation involves unsafe code as long as it's contained, well tested and fuzzed.

Post reply on HN