News for hackers. Stuff that matters.
Re:Advice for the next 100 Rust GUIs by __benny__ on Saturday November 21, 2026 @07:48PM (#50595125)
Nice article, thank you for sharing it.

I do want to nitpick this part however:

> That’s been playing out architecturally in the choice between immediate mode and retained mode. Immediate mode is very appealing because it’s less total code and seems quite a bit simpler. And for some applications (most especially development support for games) it works well. However, I am concerned it won’t scale especially well. In short, it’s good at the first 90%, but it makes the second 90% harder. To be considered really production-ready, it has to establish stable widget identities to build and update the accessibility tree, and it has to reliably cache expensive intermediate artifacts such as text layouts (simple immediate mode often gets around this by cutting corners in text layout, which may be fine for gamedev). And of course, it pulls strongly towards a model of re-rendering everything every frame rather than exploiting layers in the compositor.

It's a common criticism but I don't think it's based on anything other than preconceived notions about rendering being slow and doing a ton of caching makes everything faster. but neither seem to be backed up by any sort of empirical evidence. Anecdotally every imgui I've used has been lightening fast, and retained mode UI's like the browser, windows software, new Macos apps written in SwiftUI, etc, have performance problems.

Egui has solved the accessibility problem and does a lot of caching: galleys, glyphs, and layouts are cached, packed texture atlases minimize GPU uploads, and it uses inputs & animation state to draw on demand.

I also don't see how retained mode UI would scale better. Retained mode UI's are typically slow - they have a complex multi-pass general layout system and a ton of bookkeeping, which is why you typically need to keep updates to a minimum and ever-more-complex change tracking systems are being built to reduce updates to a minimum. This doesn't scream scalability to me - whereas in an imgui there is a baseline overhead but adding more widgets or more frequent updates have a negligible performance impact. the worst case for retained mode is a UI which has many widgets frequently updating multiple times a second, which means you approach the update and drawing of imgui but with the additional overhead of the change tracking, bookkeeping, etc of the retained system.

Also there is nothing fundamental about imgui layout systems being limited, and in my experience it's not that difficult to build custom widgets to implement pretty much anything. Retained mode layout systems are usually declarative, where you describe a layout and hope that the system is flexible enough to support what you want, whereas with an imgui you can just directly draw and shade geometry to get whatever you want.

Otherwise, great article and I look forward to the future of Rust UI.

Re:Advice for the next 100 Rust GUIs by adastra22 on Saturday November 21, 2026 @09:10PM (#50595540)
Egui solving accessibility is news to me. Has something changed in the last year or two?
Re:Advice for the next 100 Rust GUIs by slopinthebag on Saturday November 21, 2026 @09:36PM (#50595665)
maybe "solved" is too strong but it does integrate accesskit and appears to be one of the only rust ui libs to do so.

https://accesskit.dev

Re:Advice for the next 100 Rust GUIs by shooly on Saturday November 21, 2026 @09:18PM (#50595575)
First you complain about lack of empirical evidence in discussions about rendering, and then you yourself argue against retained mode UIs using purely anecdotal evidence.

You are also often comparing imgui/egui - a library, to retained mode - a concept.

> in an imgui [...] adding more widgets or more frequent updates have a negligible performance impact

Absolute nonsense.

> Retained mode [...] hope that the system is flexible enough to support what you want, whereas with an imgui you can just directly draw and shade geometry

At least in browsers you can just use <canvas /> if you need to do that. If you're implementing retained mode in a custom application - well it also must have some way to draw things on the screen.

Re:Advice for the next 100 Rust GUIs by __benny__ on Saturday November 21, 2026 @09:50PM (#50595741)
I'm not arguing against retained mode UI systems, I'm arguing that some of the criticisms of imgui's are unfounded. A lack of empirical evidence is relevant for that.

I used Egui as an example because that's relevant to the shared article. When I say "imgui" I am talking about the paradigm, not Dear Imgui.

In manu retained mode UI systems you can break out of the paradigm with a Canvas element, but that is quite different from an imgui - it's akin to using a 2d drawing API like Skia.

> Absolute nonsense.

How so?

Re:Advice for the next 100 Rust GUIs by raphlinus on Sunday November 22, 2026 @01:02AM (#50596733)
Thanks.

The point I'm making is a subtle one. I do think you can go very far with an immediate mode GUI paradigm, and it's also certainly the case that most of the imguis you see are performant. But I still wouldn't choose it for a design or productivity app.

Once you do all the caching of text layouts and building of intermediate trees for a11y, you no longer have a pure imgui, but rather a hybrid.

I'm going to try to get this point across in an analogy, apologies to people not familiar with the referent.

Let's say you're frustrated with the size and complexity of a modern C compiler like clang or gcc, and want to do something simpler. One of the design decisions is whether use SSA (static single assignment) as the basis for the intermediate representation. If you're going for simplicity, you might quite reasonably choose to skip it; you can generate reasonably good code straight from the AST.

But then, you and your users get dissatisfied with merely reasonably good code, and want some of those optimizations that make production compilers generate actually fast code – constant folding, common subexpression elimination, strength reduction, etc. You can certainly implement them as AST transforms, but it gets difficult to track everything? You add a bunch of logic and eventually get those optimizations to work about as well as the SSA-based version in real compilers.

Another compiler designer has similar goals but uses a different strategy: dive in and do SSA from the beginning, which is not as simple at first, but then you can just do those optimizations "from the book," without a lot of friction.

Basically what I'm saying is that I prefer the second compiler. It's not to say the first can't be made to work.

Re:Advice for the next 100 Rust GUIs by __benny__ on Sunday November 22, 2026 @01:46AM (#50596926)
I guess it depends what you define as an "imgui". To me, I think it's when the application describes the UI every frame. I don't think purity of approach is very relevant though. I'm happy to concede that a hybrid approach is better - in all things, balance :)

If I understand the point of the analogy, it's basically that when you bolt sophisticated optimizations onto a representation that wasn't designed for them, the bookkeeping accumulates in an ad hoc way, while a representation purpose built for those transforms makes the same optimisations feel like they fall out of the structure. Would that be valid?

If so I would actually swap imgui's and retained mode ui's around. In an imgui, you can implement domain-specific caching and other performance optimisations for your bottlenecks, whereas in retained mode UI you're building against a general system and you often need to resort to hacks to rescue performance, or design your data model in a way that is amenable to change detection. Memoization, keys and identity gymnastics, state sliced into atoms/signals/items, "this component only depends on X" annotations, Equatable conformances, Identifiable fake IDs, keeping structs small and pruned so the diff is cheap, splitting views so diff granularity lines up with actual change granularity, id resets to force identity, etc. Fixing performance in React is largely about reshaping your data model until it's legible to the framework's change detection. When you use fine-grained reactive systems you need to adopt the framework's data stores and it ends up infecting your entire application. You cannot just pull in a dependency and use it's state directly - you need to martial it into signals or stores or set up subscribers.

Whereas in an imgui it's trivial to benchmark and if you notice that a list is performing a lot of work on each update cycle you can apply an optimisation that is impossible in a more general system.

Fwiw I'm building a desktop application with Egui and Bevy and it's been a breath of fresh air compared to building applications with classical retained-mode systems. An entire class of bugs and complexity regarding state management just goes away. Performance is ~3ms including the entire render pass (more than just UI), and all of the complex components that required caching and other performance optimisations would have had to be hand-rolled in a retained-mode system anyways - except with Egui those optimisations are simple to build. All of the state just lives in Bevy's ECS without any real considerations for the UI, because the UI systems can just reach into the world and read it directly.

But to each their own - some people seem to "click" more with a retained mode approach and it's still a valid choice to use it if you prefer it.

Re:Advice for the next 100 Rust GUIs by SleepyMyroslav on Sunday November 22, 2026 @03:22AM (#50597437)
Please consider other performance metrics like battery life. One of the new experiences for me as a developer this year was finding that platform-provided profiler can show me milliwatts spent alongside the milliseconds.
Re:Advice for the next 100 Rust GUIs by __benny__ on Sunday November 22, 2026 @05:51AM (#50598382)
Yep, generally you only draw new frames on input or if there is an active animation. But even in the most unoptimised case there isn't a massive difference

   Immediate
     Dear ImGui  7.5
     ImPlot      8.9
     EGUI        8.2
     Rerun       11.1

   Retained
     Spotify     5.8
     VSCode      7.0
     YouTube     11.5
     Facebook    8.7
https://www.forrestthewoods.com/blog/proving-immediate-mode-...
Re:Advice for the next 100 Rust GUIs by bflesch on Sunday November 22, 2026 @06:04AM (#50598473)
Did you also measure the actual refresh rates? I think the browser engines will reduce refresh rate in certain cases and not run at the full Hz of the display. This might influence the numbers a lot.
Re:Advice for the next 100 Rust GUIs by __benny__ on Sunday November 22, 2026 @06:25AM (#50598609)
> First, it must be noted that the IMGUI tests are running at a full 120 Hz with zero idle optimizations. This is to simulate a "worst case scenario" of a rich and dynamic GUI. Meanwhile the RMGUI tests are running with idle optimizations.
Re:Advice for the next 100 Rust GUIs by speedstyle on Sunday November 22, 2026 @07:41AM (#50599145)
I think almost from first principles, computing frame n+1 can share a lot with frame n. A 'fully optimal' notepad wouldn't need to recompute the previous text when you insert a character, it could just reuse that part of the draw call. So the perfect retained/reactive/incremental framework should compile down to that. It's of course hard to do that in general, or even know where to rematerialize vs cache, but I don't think the answer is redo everything. As you say even egui caches things (sometimes invalidly) and I find the application code has to maintain a lot of state too
Re:Advice for the next 100 Rust GUIs by notnullorvoid on Sunday November 22, 2026 @09:28AM (#50600031)
> they have a complex multi-pass general layout system

This is a necessity if you want to support elements that adjust their size based on contents and parent constraints. It's not something specific to retained mode. Immediate mode would also need multi-pass layout to do the same.