I think the Rust GUI scene is fast catching up. After using ArtCraft on my PC, I was amazed at the responsiveness and expressiveness of the GUIs being implemented and I feel they've come a long way. I was used to running slow JS based apps all the time, any of these native ones feel like an upgrade to me.
Having said that, I think we've come to an era where concerns like these can be quickly addressed and responsiveness tested, so looking forward to more of this kind of analysis and more usable applications in the near future.
ArtCraft mostly uses egui and without egui there isn't much that would be considered mature, even GPUI doesn't seem to have the same level of completeness.
I suppose what I'm getting at is there isn't much more movement that I've noticed as far as professional UI development. I thought there would be a lot more than there is.
Concur. I started with EGUI years ago when there were fewer options. It still seems to be one of the most mature, reliable, and flexible. I'm happy continuing to use it for new projects, with an open mind towards experimenting with GPUI and others.
I'd like to consider Slint as mature. It hasn't broken its API since 1.0 in 2023, it's used in production, and it has accessibility, live-preview tooling
(I work at Slint.)
There are no Rust bindings like the ones for Go and especially Zig. Qt and Rust would be the best but instead the focus is on QML and not Qt Widgets and not bindings.
Interesting, mitcad was released few months ago, and looks very much like https://physcad.io/ which was also released recently. The latter is commercial and closed source.
Both are clearly vibecoded but the results seem decent (haven't used them though). I wonder if there's some shared heritage or this is what you get when you prompt for a desktop CAD.
Arguing about coding languages seems quite passé. If there is an imperative reason to use something for performance reasons, I’ll bite. Otherwise, it seems silly. The prompts will not differ much and the rewrites are trivial. What matters to me is the experience, not the tech.
But there are more mature languages that are in the same performance class as Rust (e.g. C++, ObjC, Swift). Rust with an immature toolkit may be worse than WinUI + C++ or SwiftUI + Swift.
All of these languages have their own drawbacks that Rust doesn't. C++ is a toolchain management nightmare, ObjC is antique, and Swift's core team was called "toxic" by Lattner himself.
Which is not to say that Rust is a perfect language (especially for GUIs) but it's no wonder we ended up in this situation. The 14 competing standards all drove themselves into a lake.
It is possible to write software that conserves memory in almost any language. It’s easier in some languages than others. But AI makes it so that the difference between languages matters less.
If you have multiple megabytes of RAM, the language you use for GUI-related activity is basically meaningless in terms of performance. Other factors dominate massively.
I completely agree. I stopped caring about programming languages now that AI writes all the code. And AI’s are really good at C++ so that’s my weapon of choice.
What is wrong with Dart? I genuinely want to understand why such a framework exist in the first place? Why would someone write UI in Rust? That too in a framework meant for Dart with excellent ecosystem.
Performance? What is that one problem that Rust solves that Dart cannot?
If this is for fun. Great. But if this is seriously taken to prod, well.
I found Qts signal/slot system very nice to work with to help with bridging the application logic to UI events and flows. Maybe rust's generic async is all you need, but I suspect that a GUI should probably have some opinion of how it interacts with async.
I recently saw a presentation from Matthias Rauter who is actively working on Qt bridges specifically for Rust.
So in theory you could have your business logic in Rust and shoehorn a full blown QT frontend.
I am not sure if it's production ready and they are certainly open to feedback from industry but it is definitely a path forward if you want to leverage all the conformity/compliance aspects that QT already worked out through the years.
I was actually thinking the most rust ui crates Ive tried don't have an equivalent to signal/slots. I hope some will try to build a more friendly bridging framework instead of leaving it adhoc. This article focused on the rendering aspects, rightly so. But there are other untouched areas to explore for rust ui libraries. Focusing on making the app logic bridge easier and even smarter would be a big differentiator to ui crates which otherwise there are a growing pile that differ on rendering stacks and ui widgets only.
> 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.
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 specific implementation of the immediate mode concept to the whole concept of retained mode UI.
> 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> or <svg>. If you're implementing retained mode in a custom application - well it also must have some way to draw things on the screen.
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.
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.
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.
SSA isn't simply a retained representation of an AST. It's a representation with properties that make particular analyses and transformations easier. What specific properties of a retained mode UI representation make the important operations of a design application easier, and what is the cost of obtaining those properties? If the answer is stable widget identity, incremental invalidation, persistent layout relationships, and accessibility object lifetimes, thats fine, but an immediate-mode system can introduce those capabilities selectively, without necessarily adopting the entire retained-mode programming model.
In other words, the question isn't whether you need the equivalent of SSA, it's if you need to make SSA the foundation of your entire application.
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. Some parts of the UI live as entities with relationships forming a tree, so you might say that's approaching a retained-mode system, but it's implemented selectively where it's useful - most of the UI is transient.
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.
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.
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
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.
> 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.
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
> 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.
I'm building a custom GUI in Rust and it is such a slow process to build out. I find bits of the end result to be amazing, but it's all in the details that look like nothing compared to using something more "complete" with a larger UI community.
I have some nice markdown rendering and phenomenally fast smooth scrolling - but I look at everything ahead of me, I don't even have text selection implemented yet, text wrapping and input cursor placement implementation wasn't that smooth to begin with. I have some amazing shader based animations, but the amount of effort that went into far exceed anything else I could have picked for a foundation.
I started with Typescript and kept running into performance issues - it was fast to build and easy to scale, but kept becoming harder to maintain. With Rust it feels hard to build, hard to scale, but it feels like scaling and maintaining might be starting to get easier. The performance ceiling is a night a day difference though.
Text selection is particularly funny when you start getting really into it... For example RTL scripts select from right to left..except when you're selecting snippets that are LTR in within the RTL text such as numbers.
Then without a doubt various unicode quirks and features like combining characters etc will be downright impossible to ever get right.
The "2026 Survey of Rust GUI Libraries" does not include Native Shell (nsh) [1] which is retained-mode and based on gpui-fast.
Maybe because the code repository was started on October 11th, just 1.5 months ago. More than 2,000 commits later it already looks great. I think, they do the (AI) software engineering part very well [2].
After using GTK and JavaFX, and React for a decade, Native Shell makes me really excited. I never got warm with Flutter, the desktop applications were very slow on my MacBook. So I've been doing frontend development for more than 25 years, and I'm completely mind-blown for the last few weeks.
Having a React background this feels very familiar, without the annoyances. Reactivity is inspired by Solid, styling by CSS (optionally with Tailwind syntax), the UI primitives are native views with layouting done by Taffy [3]. If you target web, the UI will be HTML. You can write the UI screens and components in Rust, but you can also use TypeScript/JSX, it will transpile and interpret it using Rolldown and QuickJS.
It includes some components which are difficult to get right. A data table component, a rich-text editor component, and a plot component. As far as I can tell, they chose the currently best-known approach for them.
I'm not one of those anti-LLM people but holy ** this is the most unreadable slop website I've had the misfortune of landing on recently.
Every sentence has those instantly recognisable slop fillers that add nothing but make the paragraph longer and the technical parts are complete nonsense.
> An app written in Rust is native code compiled into the app that ships it, as the rest of that app is, and runs with its trust; its calls into NSH’s services ([...]) go through the same native checks as TSX’s, under what a host grants.
The commit messages (i.e. the pull request descriptions) are written in a similar fashion.
For example [1]: "core: Keep a device pixel for boxes under a pixel thick (#2841) [...] Frames are rounded to device pixels edge by edge (`rounded` in `core/mod.rs`), so neighbouring views meet. A box thinner than a pixel whose two edges round to the same pixel got no size at all and vanished.".
I wonder if humans need special abilities to read and understand this. And if these kind of bugs this commit attempts to fix could have been prevented in the first place.
> An app written in Rust is native code compiled into the app that ships it, as the rest of that app is, and runs with its trust
This also makes no sense if you use the Chinese version of the text and machine translate it to English.
The commit message seems fine. The bug is the following. Because boxes are rounded edge-by-edge, a box can end up with a zero size (and hence be invisible) if its dimensions are smaller than a pixel. If the box is solid, then it should display as a single device pixel in this case. That's what the bug fix accomplishes.
As for whether bugs like this could have been prevented in the first place, this seems squarely in the category of the kind of bug that humans are capable of introducing.
> Host apps download NSH apps as signed packages and run them as plugins, and an app that shipped may never be built again: its team moved on, its source sits in a business process, the host app updated NSH on its own schedule.
It’s indeed difficult when you keep your app’s source in a business process.
Looking over this project, I was startled to see how much their "Gallery" app is a clone of my own (as-yet-unannounced) Day project's Showcase app[1], which I've been developing in public since June[2] as a successor to Skip. Same example fonts. Same demo video for the media player. Same embedded web view demo structure.
I'm not ready to allege plagiarism here; I suspect it was probably just their slopbot hoovering everything up indiscriminately and no one reviewing it carefully. But it is disappointing to see a degenerate version of my work unveiled before I considered it ready to "launch" myself.
"You really want a video playing in a hardware accelerated layer when possible, and on low end devices it’s the only hope for getting smooth frame rates."
I hit this recently trying to play video in Bevy efficiently.
I thought that must be easy,
but ended up with frames copied into a texture and composited by the engine, because the app owns just one swapchain and the video can't get its own layer.
I am constantly surprised how few mentions of Slint there are in these sorts of articles. It's written by a team of funded ex-Qt alumni, is incredibly fast, and their DSL approach, while having a bit of a learning curve, makes laying out apps and managing data binding incredibly easy.
They also bypass a big part of the issues mentioned in the article by just straight up using skia as a renderer on desktop (you can use others if you want) which gives software and gpu accelerated paths.
I'm not associated with the project at all, but have been using it on and off for a couple years and have been quite satisfied.
It's main weakness is rich text rendering which lacks maturity for complex layouts, but it is getting better all the time.
They are not free. That's a pretty big barrier to adoption. When QT was launched there was no good alternative for cross platform if you want to support Linux.
Honestly, if Slint doesn't pivot or provide non GUI lib services, I would expect an "Our Incredible Journey" blog post soon.
The only way I can imagine them surviving is to go into aerospace and automobile where the barriers are entry are mostly around certification and compliance. There's no moat anymore in consumer UI libs.
On desktop and mobile, they're free for open source products and for any company with less than $2M in funding or revenue, and pretty reasonably priced otherwise.
Embedded seems to be where they're focusing, as they do charge royalties for that, so you may be right.
First, Slint is fully open source and totally free for desktop and mobile development. The article mostly focuses on that, so the pricing argument is simply not applicable in this context.
You're right about certification being a differentiator. We're currently in the process of obtaining ISO 26262 ASIL B certification, and pursuing other certifications relevant to industries such as automotive and medical.
Our customers don't necessarily want "free". They want a serious technology they can build products on, rely on and maintain for decades. They want a partner who takes responsibility and stands behind the technology.
For products with 10–20 year lifecycles, that's worth a lot more than a free library. And I believe that's where Slint's moat lies.
Isn't it rather that Slint is free and open source (but copyleft) for all development, or non-copyleft proprietary libre-enough and gratis for non-embedded work? (The gratis non-copyleft version is the specific reason I adopted Slint - thank you for listening to me on HN however many years ago!)
I’m guessing it may be a confusion of WebGPU and WGPU; WGPU as a lib works fine, but IIRC most end implementations of WebGPU in browsers are still a bit picky on support.
Could you elaborate on what you mean by resource hungry? What kind of application and hardware are you using, and what resource usage are you seeing?
I'd genuinely like to understand your experience. It might be a bug or something we can improve. (I work at Slint)
For context, Slint is designed to be lightweight. Especially compared to shipping an entire browser runtime, which appear to be considered normal by many.
Here is the resource usage for hello world counter app which comes as a template, compared with the same app written in qt - https://ibb.co.com/album/7xCbWk
For such a simple template, 70+mb is too high. I guess slint is primarily targeted for custom styled graphical apps and marketed as an alternative to Qt QML, but I imagine adding styles will only increase the consumption.
Add to that, you can check the second screenshot, where the same Slint counter app shoots up to 300MB+ Ram when i resize its window. This is strange behaviour. This doesnt happen in QT apps, atleast such a dramatic increase.
When i was exploring slint, it looked very appealing, markup and styling were not that too hard to understand, but it turned me off when i saw the resource usage. I guess slint is still better than Avalonia or even flutter, which touches 300MB, but I will stick to QT, specifically QT Widgets. If i need to add some custom graphics to qt widgets, QPainter is pretty powerful, and it only adds 5 to 10mb of ram use.
Thanks for the comparison! Keep in mind that there are fixed memory costs for font caches and GPU/driver resources that don't scale with application size. So a Hello World app might not be the most representative benchmark.
If RAM is an issue, Slint's software renderer uses considerably less memory.
(and even 70 MB is not particularly resource-hungry compared to other UI frameworks, especially browser-based ones.)
the spike when resizing is interesting and worth investigating
Electron binary itself weighs about 200MB so your number doesn't look realistic and probably you used some tool that shows wrong numbers (like Windows or Mac Task Manager).
What does the binary size have to do with memory usage? an Electron binary bundles chromium engine which includes a lot of stuff that a counter app won't load into memory (e.g all the video, audio, camera, 3d, biometric, animation, etc)
It's the same method used to measure Qt or Slint above.
Maybe 80 MB is only private pages and excludes memory-mapped files. Then the memory usage is calculated wrong. I wish people were using proper metrics and not random number Task Manager shows.
Sigh. You can use the same method for all 3 and compare them. I get the irrational hatred towards electron and other WebView based UI framework, but no matter how you measure it those are the basic numbers. Like it or not, WebView is fairly well optimized for basic use cases. It gets out of hand quickly because developers have no restraint when it comes to dependencies and features to include in their app.
> Keep in mind that there are fixed memory costs for font caches and GPU/driver resources that don't scale with application size
> If RAM is an issue, Slint's software renderer uses considerably less memory.
I can apply the same optimisation to qml and even its resource use will not scale, since they too have fixed costs with font, gpu context, js engine.
> and even 70 MB is not particularly resource-hungry compared to other UI frameworks, especially browser-based ones
70mb is extremely resource hungry for something as simple as this. When someone is using electron, they are aware of the trade off. For something which is not electron, this type of resource use is inefficient.
If I want something simple, I will use fltk. I can get far with graphics even with fltk. And if I want something powerful and not bother writing things from scratch, I can achieve that with qt easily and get fancy. I don’t know why I will use slint, other than to hop on the rust bandwagon, which is the current fad right now.
Upto you how you communicate about slint, but I am not using that, when my goal is not to hog the users resources.
I was curious, so I asked Claude to make a benchmark with this prompt: "I'd like you to make an hello world in Slint (skia GPU and software renderer), EGUI, electron, QML, QWidget, and measure the RAM usage."
(The GPU rows ran on Mesa's software drivers)
I think QML intrinsically takes more memory: it has a JS engine, and every item is a dynamic object. In Slint, almost everything is resolved at compile time and compiled.
I glanced though the docs; they seem to use proxies for dependency tracking (Vue-like rather than React-like) but for some reason they invented their own language instead of using Rust.
I honestly can’t stand Qml/Slint syntax because it mixes in a javascript lite language on top of the Qml + Rust/C++ languages. My Qml/slint files all start looking like jQuery single file scripts from yesteryear. Eventually reading my project makes me feel like a deer in headlights trying to remember if the femur bone connects to the jaw bone.
When I made a computer use tool on macOS, my tool could find the right button easily, because well made apps have buttons with a role and a name.
But I made my tool find the right button using screenshots at bad apps.
Native in this context refers to the UI toolkit(s) native to the platform. Microsoft has a big list of them, with different visual styles, and applications are split between them.
> The reasons for slow adoption may be melting away. Writing Rust code is harder than languages more traditionally used for UI (TypeScript, Kotlin, Swift), and finding engineers skilled in both Rust and UI is challenging. But AI is changing the game. There’s evidence that the LLM cost of writing Rust code is not significantly higher than other languages, and there is reason to believe that in large codebases, Rust will be more maintainable because its type system helps enforce invariants. So if all languages have roughly the same cost, then why not go with one that has a dramatically better combination of safety and performance?
IOW, you're not going to write nor read any code, so choose Rust.
(Of course, if you're not going to write nor read any code, you might as well choose anything).
> RAM remains expensive and the focus is shifting to mobile, so bloat has real consequences. Building high-performance UI in Rust is a practical alternative.
The blogger is making the mistake of trying to come up with problems where Rust is the solution.
The truth of the matter is that both Android and iOS have native, high performance GUI toolkits. Yet, some mobile apps developed by sizeable professional teams led by smart software engineers still opt to develop them with webview-based technologies. Why would this happen if the blogger's argument was grounded on reality?
The truth of the matter is that webview-based technologies are already quite performant and run well with the resources of your average phone. Native GUI toolkits moreso.
Also, today's mobile phones have far more computational resources than your average workstation from 20 years ago, and back then people were fine with using Java-based desktop applications. So to claim that today there is a premium for performance that didn't existed decades ago is an extraordinary claim that is not really supported by reality.
But again that's why the blogger had to at least try to come up with a problem where Rust for GUI programming was a reasonable solution. It's a shame the problem simply isn't real.
There is a significant trend, ever since LLMs arrived on the scene, of companies porting their web-based UIs to native - at least in part driven by persistent criticism of the RAM usage of Electron apps.
> There is a significant trend, ever since LLMs arrived on the scene, of companies porting their web-based UIs to native - at least in part driven by persistent criticism of the RAM usage of Electron apps.
I don't think you are seeing any trend.
I see a constant back and forth between webview-based technologies, webview-to-native transpires, and native. This has been happening constantly for a decade or so.
If anything, what you are seeing is the bar for these rewrites to be lowered by code assistants.
On top of that, webview-based UIs are the backbone of server-driven UI, which is a well established technique to circumvent problems created by appstore reviews. Any team that has a healthy throughput eventually migrates toward server-driven UI to avoid appstore bottlenecks.
So no, I don't think that you are seeing any trend at all. At best you are seeing people doing unimportant tasks just because ai code assistants lowered the cost of doing experiments.
I wouldn’t call ArtCraft apps snappy by any means. It’s fine if you work on mostly-empty projects or on a really beefy MacBook, but most professional video creators I’ve watched or asked describe lag spikes whenever e.g. moving clips on a timeline making the software nearly unusable.
(Lag spikes when a lot of things are on screen and just one thing is changing is, I might add, a very classic shortcoming with immediate mode GUIs, because unlike retained-mode GUIs they can’t optimize what to redraw or pre-generate textures for existing UI elements)
> You really want a video playing in a hardware accelerated layer when possible, and on low end devices it’s the only hope for getting smooth frame rates
The other issue in this bucket is being able to embed a 3D rendering context into the UI.
None of the native rust UI toolkits I tested at the time supported this, and I ended up using Tauri -> HTML-Canvas -> WebGL for what ought to be a native app.
Right, but going that route gives up native text layout, native IME, native accessibility, etc. It's mostly fine for building game-like things, but I wouldn't want to build a productivity app that way.
I don't know what you're asking. I use EGUI + WGPU for a 3D molecule viewer/editor, and it works great. I don't know what a productivity app is, but I think this is one?
This is what you posted:
> The other issue in this bucket is being able to embed a 3D rendering context into the UI.
Many people pointed out that you have a big selection of tools that can do this.
> Many people pointed out that you have a big selection of tools that can do this.
The vast majority have pointed to tools that do the opposite: they render the UI into my 3D context, not tools that can render my 3D context into their UI.
This is a fundamentally different approach, with significant tradeoffs: you are accepting non-native controls, text layout, IME, accessibility, no direct compositor integration, and re-renders affect the entire UI (not just the 3D viewport).
> I use EGUI + WGPU for a 3D molecule viewer/editor, and it works great
I believe we have chatted about this specific app in some other UI threads on HN, and it looks like a great app, but it's not the sort of data-binding-heavy UI that really stresses a UI toolkit
what do you mean by "native text layout, native IME, native accessibility"? egui does text layout, accessibility, etc. if you mean like using the os-native UI, tauri doesn't give you that either...
> if you mean like using the os-native UI, tauri doesn't give you that either
The browser shell offers a mature text engine, native IME integration, robust accessibility support, access to a wide selection of controls that behave exactly like their native equivalents, and the canvas element is distinct from the rendering model of the surrounding UI elements.
It's not a panacea, but its significantly more advanced than something like egui.
the browser has it's strengths and weaknesses, if it works for your usecase than great. but i thought we were talking about embedding 3d context into rust ui :)
You can check my IUP fork here https://github.com/gen2brain/iup-go , with many drivers/backends for the native controls. And they all have Canvas and GLCanvas controls. Well, maybe not modern, but still the only easy cross-platform API to handle different platforms with more or less the same codebase.
And of course, no need to use Go, you can use C, there is a nice wrapper for C++. You can also build IUP.xcframework and use Swift if you like, and there is a bindgen example that can generate Lua and Python bindings, or can export API model as JSON so you can generate whatever bindings. Simple C API based on IUP and attributes, but very poverfull. Nice docs and 200+ examples, retained, standard events and callbacks, should be easy to start and fast to build native apps everywhere.
It's because it is an unbelievably difficult and quite finicky thing to support, especially if the 3D canvas uses a different rendering API than the UI framework itself.
For example, say your UI is drawn with OpenGL, but you need an embedded Vulkan canvas. This takes a huge amount of API-specific code passing API-foreign texture handles and synchronization objects between contexts. You need to do this for every possible combination of APIs, and it's not symmetrical (hosting Vulkan within OpenGL is different from hosting OpenGL within Vulkan).
Every desktop-class rendering API does have extensions for dealing with foreign APIs, but it's a lot of work, to the point where rendering into shared memory from a subprocess is sometimes the most viable option.
> especially if the 3D canvas uses a different rendering API than the UI framework itself
See this is high on the list of things I do not want. I don't want my UI rendered from scratch in OpenGL, I want it drawn using the native widget API, which already supports embedding 3D canvases.
This is one of those things that is completely trivial in, say, Cocoa, but arbitrarily hard in most cross-platform UI toolkits.
Sure, but that's just because Apple already did the work, and they only have to support Metal and to a limited extent OpenGL anyway.
On a Windows desktop, you have D3D11 and below, D3D12, Vulkan, and OpenGL. I believe you can do most of it if you're using GDI, but even Microsoft's own myriad of UI frameworks have spotty support.
Slint can do that. You can render with wgpu or OpenGL into a texture and show it as an Image. There are examples for wgpu, OpenGL and Bevy in the repository.
Which ones did you test? My framework Dioxus Native allows this. I believe Iced, Slint, and egui all do too. Which is all of the most popular frameworks except GPUI.
You don't embed a 3D rendering context but rather you have a render target (surface) integration such as being able to share a resource such as a window handle for rendering into with OpenGL
I wonder if there are any UI libraries inspired by how Unreal Engine does it (there it is called Slate). It does not lend itself to Rust 1:1 due to how its TAttribute type would clash with the borrow checker but it is a proven retained mode approach (with an IM adapter as of recently). It has IME, accessibility, cross platform, performance and GPU all figured out (or at least good enough). It has its issues, too, but I never see it mentioned in these discussions.
"There have been roughly 20 Rust GUI toolkits announced since that blog post (see 2026 survey)"
As an industry, I'd rather see 3 healthy competitors rather than 100 or 1. This is obviously not limited to librairies in the rust programming language, and amusingly directly applies to the existing ~100 widespread programming languages.
Not sure how other industries fare on that, the grass is always greener on the other side of the fence.. but it feels like some do better than others. I don't see reinvented 5 wheeled cars every day (although some tech guy just boasted about a flying car recently)
I love the diversity for toys/art/demos/research/... but not so much for industrial work
I'm running nightly performance comparison between all recently hyped GUI frameworks (rust and not rust) https://samoylenkodmitry.github.io/Cranpose/?tab=performance
It tests both immediate and retained heavy layouts on the same hardware (Mac M3Pro)
I think immediate-mode UI is awful (does lot of useless work, redraws whole window on every mouse move). Also I think GPU support is not that important:
- first, GPU requires shaders compilation which is slow so you need CPU renderer anyway
- second, not all GPUs are supported, not all have drivers, some are buggy and many machines, like VM, do not have a GPU
- third, it probably uses lot of memory
You don't need a GPU to add one letter to a text field.
I did some tests in a GPU-less VM, using one x86-64 core. The test simply rendered black and white 4K frames. Rendering to memory gave numbers like 360 fps (and ~8GiB/s of RAM writes). Rendering to X server via SHM produced something about 80 fps, the X server used 50% of the core and the program used other 50%. But many users have much smaller screens, and you typically do not need to redraw whole window every frame.
So you can render everything on a CPU and, if the user has a GPU, use it to accelerate drawing rounded rectangles which make probably 90% of GUI.
When using Wayland, you have 2 buffers that you render your window into, and they already contain previous window content so why make a cache? Why not simply skip the parts that did not change?
The article you are referring to is interesting, but it looks like adding a hack instead of rewriting the code. They also did not make measurements for an older system without a working GPU.
> If rebuilding the UI takes a millisecond at most, how much should we care?
Because user runs multiple programs, and rendering UI doesn't always take milliseconds, and battery capacity is not infinite. Also programs using GPU typically use lot of extra memory, require slow shader compilation, GPUs often have buggy drivers.
Also it would be better if every program used same UI widgets (for example, GTK) rather than have their own set of widgets with missing features like IME support, different hot keys etc.
Also, what is the advantage of immediate mode UI over proper GUI reactive framework with convenient declarative syntax? I see no advantages.
Pegging the CPU while scrolling - a common action that takes a full rerender - is not good enough in this day and age. Your best case scenario still doesn't achieve the minimum for a 4k120hz display. Take into account text with subpixel-antialiasing, and that resolutions scale to ok now and you'll quickly find CPU rendering unusably slow.
Shader compilation basically doesn't matter. The number of shaders needed for a GUI toolkit is tiny, and none are particularly complex. In my experience it doesn't appreciably add to the startup time.
I do agree there should still be CPU rendering for when the GPU doesn't work. It's a particularly useful feature for old or virtualised hardware.
Scrolling should not take a full render - you ideally only need to render a small stripe that becomes visible. For example, if you scroll at 720px/sec, at 120 fps you need to render only 6 px of height per frame. Must not be hard.
For example, if you are scrolling a PDF you could theoretically "scroll" (change start y offset) of the window buffer, render a newly visible stripe (those 6px) and re-render the toolbar 6px lower which otherwise would scroll with the window.
It seems nobody can do this nowadays, so another option is to use two layers - a document and a toolbar and offload the compositing to window compositor which might as well use GPU for that. So you have one buffer with a toolbar (never changes), and another buffer with a document, and when scrolling, you only draw the changed part and instruct the compositor to draw the document with an offset.
Surprisingly, it's often faster to do a full render than to copy pixels around in the framebuffer, for two reasons.
1. With discrete GPUs, which have their own VRAM (unlike integrated GPUs), reading the framebuffer is often much slower than reading main memory.
2. If you're copying pixels around in the framebuffer, the best you can do is memcpy speed, which spends half of the memory bus bandwidth on reading memory. But if you're computing fresh pixels to put in the framebuffer instead, you can go about twice that fast. Sometimes more than twice that fast. As a simple example, https://canonical.org/~kragen/sw/dev3/bgraify.c unpacks 1-bit-deep bitmaps with a palette of two 32-bit colors on one core at 26 gigabytes per second (on this Ryzen 5 3500U), while memcpy() on that same core can only reach about 10 gigabytes per second. (memcpy() on two cores reaches more like 18 gigabytes per second, so the naïve extrapolation is that you ought to be able to hit 36 gigabytes per second for something like a solid-color fill.)
I do not see where I suggested to copy the pixels with CPU. With compositors like Wayland, you have a buffer in memory that stores content of a window. Obviously writing a 6-pixel stripe into that buffer (and updating starting Y offset) is faster than over-writing the whole buffer. Now, if that buffer is directly accessibly by GPU, you do not need to copy nothing. And I assume that even poor discrete GPUs can copy that 6 rows with pixels from system RAM to their memory for compositing.
Also your URL shows 404 for me.
To scroll the content you do not need to copy anything. You can just tell the compositor: "first render rows 6-1000 from this buffer and after that rows 0-5". That would look like the content has scrolled 6px up without a single copied byte. This trick was used by game consoles on 80s.
I'm sorry about the URL; I've fixed it now. Let me know if it's still broken.
Yes, you can scroll by telling the GPU to use a different starting address for its framebuffer, but only if you're scrolling the whole screen. If you want to scroll the contents of a browser window but not the browser chrome, though, or one window but not another, you start needing to tell the GPU to composite things from a few different textures, or needing to copy things around in system RAM. If you push this work off on a software compositor like Wayland, you aren't saving any work; you're just changing which process does the work.
> you start needing to tell the GPU to composite things from a few different textures,
Yes, correct, you need to have two buffers - one for the document, another for the toolbar. In this case you need to do compositing. The good thing is that compositing here is just memcpy, and it can be done on CPU and almost on any GPU starting from 90s, no need for Vulkan support or NVIDIA proprietary driver. And compositing (memcpy) is faster than rendering complicated document from scratch. So instead of sending one large buffer to Wayland, you send two smaller buffers ("send" doesn't imply copying here as Wayland uses shared memory).
So in a perfect world, the application updates a small part of a buffer with a document in a shared memory, changes Y offset, and CPU or GPU rebulds the window that was scrolled by combining the document and toolbar buffers. Oh, even better, by copying only the document part into a framebuffer because toolbar did not change.
So for example, if you are scrolling a text document, with my approach you need to render only one line of text (that became visible) and you reuse previously drawn lines. But with "immediate mode" approach, all visible lines must be re-rendered every frame.
> And compositing (memcpy) is faster than rendering complicated document from scratch.
Again, I don't think this is generally true, and that was the specific point I was investigating with bgraify.c. You can potentially render a complicated document from scratch, on the CPU, at speeds closer to memset() than to memcpy(), getting more than a 2× speedup.
And, on the GPU, you can do it at texture-mapping speeds, which are much faster still. (The basic plan is that you put the glyphs of your font into a texture atlas which your fragment shader texture-maps, possibly using SDF thresholding.) rxi's MicroUI https://github.com/rxi/microui is an example of a very small, simple IMGUI library whose standard backend works this way on top of OpenGL.
Let's say you scroll text. I believe rendering one line of text (that became visible) on each frame, and reusing previously rendered lines is faster than rendering all text on every frame. Text rendering is not an easy task.
And as I have written above, you can offload compositing (memcpy) to any GPU from 90s while rendering letters is a harder task. Even with glyph cache you need to manage it, upload updates to GPU etc. So much easier to not use GPU for this.
I don't believe that reusing previously rendered lines is faster than rendering all text on every frame. I don't know why you keep repeating this when I've already explained why I think it isn't true; you haven't presented any counterarguments. In case you just didn't understand what I was saying, I'll explain it more plainly.
Text rendering can be made arbitrarily complex, but in most cases it is not. In Russian, most Spanish, most Japanese, Ukrainian, or English, code points map 1:1 to glyphs, and figuring out where each glyph belongs on a line is a matter of running a prefix sum over their advances. AVX-512 prefix sum on 32-element vectors is about 2 nanoseconds per 32-element vector, so you need about 5 nanoseconds of layout time per line and about 200 nanoseconds for the whole screen, say 250ns to include the time to check for exceptional cases and figure out where each line belongs on the screen. This gives you a display list of some 3000 glyphs at various places on the screen.
If you rerender 2 megapixels from that display list at, say, 5 gigapixels per second on the CPU, it's going to take 400μs, which is 400,000ns. (I think the evidence I've shown above strongly suggests that this is doable on my laptop here, although it isn't a proof.)
If, instead, you copy 2 megapixels from one place to another in RAM, you can only do that at about 2.5 gigapixels per second, so reusing previously rendered lines will take more like 800μs.
That is slower than 400μs.
It is not faster than 400μs.
If you, instead, pass the display list to the GPU to texture-map from the font atlas, well, this GPU has a theoretical peak texture fill rate of 38.4 gigatexels per second, so it will take more like 52 μs. On the GPU, you can't really reuse the previously rendered lines.
Again, 800μs is slower than 52 μs. It's not faster.
The GPU doesn't really mind rendering 3000 quads instead of two or three. The difference is down in the range of [correction!] microseconds; this GPU can in theory do one triangle per clock at 1.2GHz, so each quad takes about 1.7 nanoseconds, and you can do 3000 of them in 5μs, about 10% of the total. But this is running concurrently with the fill rate, so it doesn't increase the 52μs.
The key thing to note, though, is that even the 800μs you would get by foolishly reusing previously rendered lines is still pretty small compared to the frame time, which at 60fps (what my laptop can actually run at) is 16667μs, 20 times longer. If you parcel that out among the 3000 or so glyphs on the screen, you have almost 5.6μs to do all the text layout calculations for each glyph: kerning, ligatures, shaping, whatever.
It's true that you need to manage the texture atlas, glyph cache, etc., although multichannel SDF fonts can provide reasonable antialiased results at a fairly wide range of pixel sizes, which can reduce this load quite a lot.
First, the data is sent to the monitor from a framebuffer. With compositors like Wayland, every window has its own buffer, and when it is damaged (updated), the compositors copies (memcpy) the damaged part from window buffer into the framebuffer using CPU or GPU. As I understand, this part cannot be skipped and the application renders window content into a window buffer so there always will be a memcpy stage to have it actually displayed.
For example, if the button changed its color, the program updates button image in window buffer, reports the damaged rectangle and the compositor copies that change into the framebuffer to become visible.
Actually compositors use two buffers to prevent tearing, and switch between them on every update so the things might be more complicated.
So with this model in mind, updating one line of text in a window buffer is faster than updating the whole buffer.
Furthermore, to render the text you need to memcpy the glyphs from glyph cache into their locations. So rendering whole window of text boils down to lot of small memcpys.
Also, you mention AVX-512 but I don't think my CPU has it. And when doing lot of 256-bit SIMD the CPU starts throttling to 1GHz-level speed. Also, you mentioned display lists but that requires extra memory compared to my approach.
Also, I decided to try to actually benchmark rendering text from a glyph atlas. Luckily, LLMs can write such code in matter of minutes, so I wrote it: https://pastebin.com/7baP4tWv
Results in a VM without a GPU:
Buffer 3840 x 2160 px, grid 295 cols x 90 rows = 26550 letters/frame, 10 runs, avg per frame: 7.832 ms, time per letter: 295.0 ns, letters/second: 3390088, pixels/second: 1059.086 Mpx/s.
I also godbolt'ed the hot loop in case you are curious about the assembly - it seems to use 128-bit SIMD and unrolled the single glyph rendering loop: https://godbolt.org/z/1Gh1McKE8
Even without the GPU, you don't have to peg the CPU when scrolling a 4K 120Hz display. 3840 pixels/row × 2160 rows/frame × 120 frames/second × 4 bytes/pixel is 4 gigabytes per second. The laptop I'm typing this on can memcpy() to main memory at 10 gigabytes per second on one core and 17–19 gigabytes per second on two cores. So we're talking about more like a 25% CPU load if we can avoid extra copies, maybe better than that if most of the work is something like colormapping 8-bit grayscale font-glyph pixels.
(If you're mostly memcpying from a font that fits in cache, you should get a higher fill rate than this.)
Using a GPU is of course much better, but not necessary to reach the level of performance you're talking about.
> I think immediate-mode UI is awful (does lot of useless work, redraws whole window on every mouse move). Also I think GPU support is not that important:
If you're concerned about efficiency, GPU support is very important. But IMGUI is not the efficiency enemy you think it is; while IMGUI libraries do need to traverse the hierarchy of visible objects on every mouse movement, there are generally only a few dozen rectangles and a few thousand letters and other graphical objects visible, so the work involved in traversing them is generally very small amount compared to copying a few million pixels into the framebuffer.
As an example, I currently have a browser viewing HN and an Emacs window open, and they total about 3000 characters (1523 mostly-blank characters and 206 words in Emacs, 335 words in HN, plus chrome), a couple dozen icons, and another dozen or so roundrects. But my screen is 2 million pixels.
So the amount of per-drawable work has to be almost three orders of magnitude larger before the per-pixel work isn't the dominant factor.
IMGUI libraries do have to do a bit more work to avoid redrawing all those pixels on every mouse movement, but many popular IMGUI libraries, such as React, do in fact do that work. It's a somewhat less simple job than for retained-mode GUI libraries like Qt (or the browser DOM), but the added complexity in the IMGUI library often pays off in simpler and more reliable apps.
Only in a hello world application. Every professional editor like GIMP has tons of tiny widgets. And redrawing one tiny widget on mouse over is faster than running the render function.
Also, you are assuming that running render function costs nothing while in real-world apps there will be layout calculations (because you don't want to position widgets manually), array iteration (for example, to display a sum and average of values from a 100K element array), text characters layout, calling helper functions, generating SVG for a 10K points graph, some genius might add reading from a file, etc.
Yes, writing good code is harder than bad code, especially for a LLM.
And if you are on the stage where you need widgets and layout calculation, why not add a dirty flag and damage rectangles as well, I cannot understand.
You say I'm talking about a hello-world application, but I'm talking about Firefox, Emacs, and my window manager. Firefox has 10 tabs visible, 21 icons in the toolbar, five bookmarks, and about 20 HTML elements. This still adds up to a few dozen rectangles, not thousands or even hundreds.
You say I'm assuming that the render function costs nothing. I thought it was clear that I was not assuming that; what I said in the comment that you're responding to is, "The amount of per-drawable work has to be almost three orders of magnitude larger before the per-pixel work isn't the dominant factor." But you may have responded before I added that; I forget if I added it in later. Here by "drawable" I mean talking about things like letters, not widgets that have their own render functions. Widgets that have their own render functions can take more than four orders of magnitude more time than the per-pixel work before the per-widget work becomes the dominant factor.
It's true, as you say, that people are capable of using up that margin by doing things like reading from a file, because writing good code is harder than writing bad code. But that's not really a question of immediate-mode vs. retained-mode. You can write bad code with retained-mode GUI libraries, too. In fact, my experience is that it's much harder to write good code with retained-mode GUI libraries.
As for layout calculations, the layout engine I elicited from Opus 5.5 for http://canonical.org/~kragen/sw/megilloom-sandbox lays out 60,000 lines of text per second, in JavaScript, and it supports table layout. (It caches the layout calculations so that it can remain responsive up to hundreds of thousands of lines.)
Some IMGUI libraries are capable of providing a dirty flag and damage rectangles without requiring every application to duplicate the error-prone cache-invalidation logic to do that. As Raph points out in this post, they're not a panacea. But they're not as bad as you are naïvely assuming them to be.
Because writing good code is harder than bad code.
Let me give an example. I vide-coded a program that renders white and gray frames and it can do it faster than 60fps on one core in a VM with no GPU. However, VS Code in that VM feels like it is running at 5 fps. The scrolling is slow and laggy. Why is that so? Probably because writing good code is harder. And probably they were thinking like you, that redrawing the whole screen is fast enough except in fact it is not.
Every time someone says that their framework is fast, they should test it in a VM without a GPU.
Generally speaking, what distinguishes good code from bad code is that it minimizes the number of error-prone things that must be done. As Frank Borman said, "A superior pilot uses his superior judgment to avoid situations which require the use of his superior skill."
I think VS Code is slow because it's a piece of shit, not because it uses an IMGUI library. I don't think it does use an IMGUI library; I think it uses src/vs/base/browser/ui which is all retained-mode.
VS Code runs in Node, which is fundamentally mostly a single-event-loop system, and in general it's very difficult for large single-event-loop systems to be reliably responsive, because literally any loop, anywhere in the system, that runs for too many iterations, will cause it to start janking. That's a problem with browser apps, too. Erlang-style actor systems have a much better chance, but they can still run into unexpected head-of-line blocking problems.
I have some experimental designs for software transactional memory systems which I hope will solve this problem...
Rust is almost by very definition (aka compile time borrow checker complexity) unsuited to most projects - it implies considerable overhand and added complexity; it bears fruit only when that extra complexity is warranted.
AI is not a magic pill - it makes Rust more accessible, but the inherent complexity remains.
The AI reasons better with other languages for the same reason that humans - there's less to think about.
The added 'structure' of Rust is does not improve the coherence of the logic of the problem space aka it does not solve the problem of what goes in where bank account or what goes where on someone's screen - it solves the problem of 'what goes where and for how long in cpu memory and what can access it'.
Rust helps to solve implementation issues not user-problem issues.
By all means - have fun with this stuff, experimenting and hacking is fun, but it's definitely swimming upstream.
If you goal is to make a nice, clean UX platform in the age of AI you probably would not choose rust - unless you're 'start with Rust and work backwards' ...
It's 'very good for what it's good for' ... not so much other things.
This is my experience as a framework (soon to be released) author too.
I am doing something that is a bit fringe/frontier concept wise and rust semantics are a no go. In fact, I asked claude to figure out if I could port the framework to Rust since I have written it in two languages already but it is apparently not too possible.
Even when people were still reading code, there was a steep curve in understanding the semantics...
But there is a basic issue which is rust is limiting wrt some datastructures.
Rust is great for business logic but I don’t know if it has any features that make it specifically good for UIs. Rust UIs can be less resource-hungry than Electron, but that bar is very low.
But one thing that’s great about coding agents is that they make technical debt much less of a problem. So you can freely pick a framework and if it ends up being a bad idea, it’s no big deal to switch to something else.
I've been working on an animation tool as a side project for really far too long and maybe I've got some interesting 'left-field' approaches to the problems outlined here. Not sure if it's interesting to anyone other than me, though, I've never really got that much engagement. Still, the article says 'be bold'.
What I hit early on with this project is that Rust's ecosystem is very dynamic and whatever I picked wouldn't be current later on and I'd need to replace it. So that's the problem I worked on solving, and I think it's produced something quite interesting.
Core idea is to communicate using streams and not function calls, because you can replace the receiver or map streams to new streams when an API changes. `flo_scene` is the crate I came up with to implement this. It's sort of an actors framework but as it's more to achieve specific goals than implement the theoretical idea of what an actors framework should be it's got its own names for things.
flo_scene divides up large software into 'sub-programs' that talk by sending messages. The dependencies are all defined externally which makes a huge difference to how complexity evolves as software grows: a sub-program that wants to draw something just sends drawing requests without needing to know exactly what or how those requests are realised later on. Similar for displaying a UI: it's just messages that something else handles so replacing the backend is surprisingly easy.
Eg: the old version of FlowBetween can switch between a web app and a Mac OS native app just by changing where it sends the UI messages to: it's a really effective approach at making it so dependencies are always shallow and easy to replace no matter how much stuff is built around them. It can run as both at once too (even weird stuff like mirroring your desktop session as a fully HTML web app), which I think is an entirely unique capability.
Then there's flo_draw which is the rendering library I came up with. This has the same non-monolithic approach to rendering graphics, which lets you do some neat things. One is the very straightforward initialisation it has if you just need a window to draw in (I kind of wanted to get to the point where you could draw stuff the same way you can println stuff but some UI frameworks see the main thread as 'special' so that's not possible) The other is how it lets you compose multiple sources into a single drawing: it has namespaces so that resources can be loaded without conflicting with each other. It has layers so it's possible to combine the output of many sources into a single output. As everything is a stream you can use it as an immediate mode or a retained mode renderer: because it has layers you can do both at once. Last thing it has at a high level are sprites, which are a way to repeatedly render a set of instructions - a modernised version of the old concept - and thus are a generalised composition mechanism.
vkaku | 21 hours ago
Having said that, I think we've come to an era where concerns like these can be quickly addressed and responsiveness tested, so looking forward to more of this kind of analysis and more usable applications in the near future.
skhameneh | 18 hours ago
I suppose what I'm getting at is there isn't much more movement that I've noticed as far as professional UI development. I thought there would be a lot more than there is.
the__alchemist | 18 hours ago
ogoffart | 12 hours ago
codedokode | 3 hours ago
amelius | 21 hours ago
throwaway2037 | 15 hours ago
monocasa | 14 hours ago
RustSupremacist | 2 hours ago
* https://github.com/mappu/miqt
* https://github.com/rcalixte/libqt6zig
progbits | 12 hours ago
Both are clearly vibecoded but the results seem decent (haven't used them though). I wonder if there's some shared heritage or this is what you get when you prompt for a desktop CAD.
amelius | 9 hours ago
anthk | 8 hours ago
odo1242 | 2 hours ago
JohnAaronNelson | 20 hours ago
palata | 19 hours ago
wmf | 17 hours ago
bigyabai | 16 hours ago
All of these languages have their own drawbacks that Rust doesn't. C++ is a toolchain management nightmare, ObjC is antique, and Swift's core team was called "toxic" by Lattner himself.
Which is not to say that Rust is a perfect language (especially for GUIs) but it's no wonder we ended up in this situation. The 14 competing standards all drove themselves into a lake.
kccqzy | 16 hours ago
Dylan16807 | 14 hours ago
bliteben | 19 hours ago
deterministic | 18 hours ago
jacoplane | 20 hours ago
himujjal | 18 hours ago
Performance? What is that one problem that Rust solves that Dart cannot?
If this is for fun. Great. But if this is seriously taken to prod, well.
Rohansi | 15 hours ago
dv_dt | 20 hours ago
pedro_caetano | 13 hours ago
So in theory you could have your business logic in Rust and shoehorn a full blown QT frontend.
I am not sure if it's production ready and they are certainly open to feedback from industry but it is definitely a path forward if you want to leverage all the conformity/compliance aspects that QT already worked out through the years.
dv_dt | 13 hours ago
__benny__ | 20 hours ago
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.
adastra22 | 18 hours ago
shooly | 18 hours ago
You are also often comparing imgui/egui - a specific implementation of the immediate mode concept to the whole concept of retained mode UI.
> 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> or <svg>. If you're implementing retained mode in a custom application - well it also must have some way to draw things on the screen.
__benny__ | 17 hours ago
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?
[OP] raphlinus | 14 hours ago
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.
__benny__ | 14 hours ago
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.
SSA isn't simply a retained representation of an AST. It's a representation with properties that make particular analyses and transformations easier. What specific properties of a retained mode UI representation make the important operations of a design application easier, and what is the cost of obtaining those properties? If the answer is stable widget identity, incremental invalidation, persistent layout relationships, and accessibility object lifetimes, thats fine, but an immediate-mode system can introduce those capabilities selectively, without necessarily adopting the entire retained-mode programming model.
In other words, the question isn't whether you need the equivalent of SSA, it's if you need to make SSA the foundation of your entire application.
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. Some parts of the UI live as entities with relationships forming a tree, so you might say that's approaching a retained-mode system, but it's implemented selectively where it's useful - most of the UI is transient.
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.
SleepyMyroslav | 12 hours ago
__benny__ | 9 hours ago
bflesch | 9 hours ago
__benny__ | 9 hours ago
speedstyle | 8 hours ago
notnullorvoid | 6 hours ago
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.
skhameneh | 18 hours ago
I have some nice markdown rendering and phenomenally fast smooth scrolling - but I look at everything ahead of me, I don't even have text selection implemented yet, text wrapping and input cursor placement implementation wasn't that smooth to begin with. I have some amazing shader based animations, but the amount of effort that went into far exceed anything else I could have picked for a foundation.
I started with Typescript and kept running into performance issues - it was fast to build and easy to scale, but kept becoming harder to maintain. With Rust it feels hard to build, hard to scale, but it feels like scaling and maintaining might be starting to get easier. The performance ceiling is a night a day difference though.
samiv | an hour ago
Then without a doubt various unicode quirks and features like combining characters etc will be downright impossible to ever get right.
tauchunfall | 18 hours ago
Maybe because the code repository was started on October 11th, just 1.5 months ago. More than 2,000 commits later it already looks great. I think, they do the (AI) software engineering part very well [2].
After using GTK and JavaFX, and React for a decade, Native Shell makes me really excited. I never got warm with Flutter, the desktop applications were very slow on my MacBook. So I've been doing frontend development for more than 25 years, and I'm completely mind-blown for the last few weeks.
Having a React background this feels very familiar, without the annoyances. Reactivity is inspired by Solid, styling by CSS (optionally with Tailwind syntax), the UI primitives are native views with layouting done by Taffy [3]. If you target web, the UI will be HTML. You can write the UI screens and components in Rust, but you can also use TypeScript/JSX, it will transpile and interpret it using Rolldown and QuickJS.
It includes some components which are difficult to get right. A data table component, a rich-text editor component, and a plot component. As far as I can tell, they chose the currently best-known approach for them.
[1] https://nsh.dev/ [2] https://github.com/longbridge/nsh/commits/main [3] https://nsh.dev/elements/
franga2000 | 11 hours ago
Every sentence has those instantly recognisable slop fillers that add nothing but make the paragraph longer and the technical parts are complete nonsense.
This is probably the craziest example one click from the front page: https://nsh.dev/docs/sandbox-and-capabilities/
> An app written in Rust is native code compiled into the app that ships it, as the rest of that app is, and runs with its trust; its calls into NSH’s services ([...]) go through the same native checks as TSX’s, under what a host grants.
WHAT??
tauchunfall | 10 hours ago
For example [1]: "core: Keep a device pixel for boxes under a pixel thick (#2841) [...] Frames are rounded to device pixels edge by edge (`rounded` in `core/mod.rs`), so neighbouring views meet. A box thinner than a pixel whose two edges round to the same pixel got no size at all and vanished.".
I wonder if humans need special abilities to read and understand this. And if these kind of bugs this commit attempts to fix could have been prevented in the first place.
> An app written in Rust is native code compiled into the app that ships it, as the rest of that app is, and runs with its trust
This also makes no sense if you use the Chinese version of the text and machine translate it to English.
[1] https://github.com/longbridge/nsh/commit/70a45b59ea5813bbc5f...
foldr | 10 hours ago
As for whether bugs like this could have been prevented in the first place, this seems squarely in the category of the kind of bug that humans are capable of introducing.
eddythompson80 | 10 hours ago
It’s indeed difficult when you keep your app’s source in a business process.
maxipavlovic | 6 hours ago
However, the project seems curious still. I see using it for some fast prototyping.
marcprux | 6 hours ago
I'm not ready to allege plagiarism here; I suspect it was probably just their slopbot hoovering everything up indiscriminately and no one reviewing it carefully. But it is disappointing to see a degenerate version of my work unveiled before I considered it ready to "launch" myself.
[1] https://daybrite.dev/showcase/ [2] https://news.ycombinator.com/item?id=49261607
weinzierl | 18 hours ago
I hit this recently trying to play video in Bevy efficiently. I thought that must be easy, but ended up with frames copied into a texture and composited by the engine, because the app owns just one swapchain and the video can't get its own layer.
dafelst | 17 hours ago
They also bypass a big part of the issues mentioned in the article by just straight up using skia as a renderer on desktop (you can use others if you want) which gives software and gpu accelerated paths.
I'm not associated with the project at all, but have been using it on and off for a couple years and have been quite satisfied.
It's main weakness is rich text rendering which lacks maturity for complex layouts, but it is getting better all the time.
Onavo | 17 hours ago
Honestly, if Slint doesn't pivot or provide non GUI lib services, I would expect an "Our Incredible Journey" blog post soon.
The only way I can imagine them surviving is to go into aerospace and automobile where the barriers are entry are mostly around certification and compliance. There's no moat anymore in consumer UI libs.
dafelst | 17 hours ago
Embedded seems to be where they're focusing, as they do charge royalties for that, so you may be right.
ogoffart | 12 hours ago
MisterMunchkin | 2 hours ago
ogoffart | 13 hours ago
First, Slint is fully open source and totally free for desktop and mobile development. The article mostly focuses on that, so the pricing argument is simply not applicable in this context.
You're right about certification being a differentiator. We're currently in the process of obtaining ISO 26262 ASIL B certification, and pursuing other certifications relevant to industries such as automotive and medical.
Our customers don't necessarily want "free". They want a serious technology they can build products on, rely on and maintain for decades. They want a partner who takes responsibility and stands behind the technology.
For products with 10–20 year lifecycles, that's worth a lot more than a free library. And I believe that's where Slint's moat lies.
weinzierl | 9 hours ago
That is where the "provide non GUI lib services" mentioned by Onavo comes in. Have you thought about that?
pie_flavor | 7 hours ago
ducktective | 15 hours ago
I think building up on wgpu is better
Narishma | 14 hours ago
mottosso | 13 hours ago
skhameneh | 3 hours ago
nicoburns | 8 hours ago
I have an abstraction which allows you to switch between the 2 (and CPU rendering options) at build time.
potato-peeler | 13 hours ago
I don’t know how you define fast, but slint is incredibly resource hungry on desktop.
ogoffart | 13 hours ago
I'd genuinely like to understand your experience. It might be a bug or something we can improve. (I work at Slint)
For context, Slint is designed to be lightweight. Especially compared to shipping an entire browser runtime, which appear to be considered normal by many.
potato-peeler | 11 hours ago
Add to that, you can check the second screenshot, where the same Slint counter app shoots up to 300MB+ Ram when i resize its window. This is strange behaviour. This doesnt happen in QT apps, atleast such a dramatic increase.
When i was exploring slint, it looked very appealing, markup and styling were not that too hard to understand, but it turned me off when i saw the resource usage. I guess slint is still better than Avalonia or even flutter, which touches 300MB, but I will stick to QT, specifically QT Widgets. If i need to add some custom graphics to qt widgets, QPainter is pretty powerful, and it only adds 5 to 10mb of ram use.
ogoffart | 10 hours ago
If RAM is an issue, Slint's software renderer uses considerably less memory.
(and even 70 MB is not particularly resource-hungry compared to other UI frameworks, especially browser-based ones.)
the spike when resizing is interesting and worth investigating
eddythompson80 | 10 hours ago
Is it? A comparable Electron hello world app is ~80-100 MBs
newdee | 6 hours ago
bel8 | 6 hours ago
codedokode | 5 hours ago
eddythompson80 | 5 hours ago
It's the same method used to measure Qt or Slint above.
codedokode | 4 hours ago
eddythompson80 | 4 hours ago
potato-peeler | 10 hours ago
> If RAM is an issue, Slint's software renderer uses considerably less memory.
I can apply the same optimisation to qml and even its resource use will not scale, since they too have fixed costs with font, gpu context, js engine.
> and even 70 MB is not particularly resource-hungry compared to other UI frameworks, especially browser-based ones
70mb is extremely resource hungry for something as simple as this. When someone is using electron, they are aware of the trade off. For something which is not electron, this type of resource use is inefficient.
If I want something simple, I will use fltk. I can get far with graphics even with fltk. And if I want something powerful and not bother writing things from scratch, I can achieve that with qt easily and get fancy. I don’t know why I will use slint, other than to hop on the rust bandwagon, which is the current fad right now.
Upto you how you communicate about slint, but I am not using that, when my goal is not to hog the users resources.
ogoffart | 9 hours ago
Results on Linux, PSS 400×200 window:
(The GPU rows ran on Mesa's software drivers) I think QML intrinsically takes more memory: it has a JS engine, and every item is a dynamic object. In Slint, almost everything is resolved at compile time and compiled.So I wouldn't call Slint resource hungry
mpweiher | 36 minutes ago
That seems like...a lot?
codedokode | 5 hours ago
righthand | 3 hours ago
pnkzin1024 | 16 hours ago
soon_to_be_sb | 16 hours ago
Wait, where did MFC go?
EDIT: https://zendevy.com/en/tech/mfc-history-and-current-status-2...
Rohansi | 15 hours ago
lelanthran | 15 hours ago
IOW, you're not going to write nor read any code, so choose Rust.
(Of course, if you're not going to write nor read any code, you might as well choose anything).
locknitpicker | 13 hours ago
The blogger is making the mistake of trying to come up with problems where Rust is the solution.
The truth of the matter is that both Android and iOS have native, high performance GUI toolkits. Yet, some mobile apps developed by sizeable professional teams led by smart software engineers still opt to develop them with webview-based technologies. Why would this happen if the blogger's argument was grounded on reality?
The truth of the matter is that webview-based technologies are already quite performant and run well with the resources of your average phone. Native GUI toolkits moreso.
Also, today's mobile phones have far more computational resources than your average workstation from 20 years ago, and back then people were fine with using Java-based desktop applications. So to claim that today there is a premium for performance that didn't existed decades ago is an extraordinary claim that is not really supported by reality.
But again that's why the blogger had to at least try to come up with a problem where Rust for GUI programming was a reasonable solution. It's a shame the problem simply isn't real.
swiftcoder | 12 hours ago
locknitpicker | 11 hours ago
I don't think you are seeing any trend.
I see a constant back and forth between webview-based technologies, webview-to-native transpires, and native. This has been happening constantly for a decade or so.
If anything, what you are seeing is the bar for these rewrites to be lowered by code assistants.
On top of that, webview-based UIs are the backbone of server-driven UI, which is a well established technique to circumvent problems created by appstore reviews. Any team that has a healthy throughput eventually migrates toward server-driven UI to avoid appstore bottlenecks.
So no, I don't think that you are seeing any trend at all. At best you are seeing people doing unimportant tasks just because ai code assistants lowered the cost of doing experiments.
cpursley | 13 hours ago
raincole | 13 hours ago
> For this reason among others, I am not impressed by the choice of the ArtCraft projects to use egui
ArtCraft apps are incredibly snappy, and they've convinced me that the stigma surrounding immediate mode is unwarranted.
malkia | 12 hours ago
odo1242 | 3 hours ago
(Lag spikes when a lot of things are on screen and just one thing is changing is, I might add, a very classic shortcoming with immediate mode GUIs, because unlike retained-mode GUIs they can’t optimize what to redraw or pre-generate textures for existing UI elements)
swiftcoder | 12 hours ago
The other issue in this bucket is being able to embed a 3D rendering context into the UI.
None of the native rust UI toolkits I tested at the time supported this, and I ended up using Tauri -> HTML-Canvas -> WebGL for what ought to be a native app.
slopinthebag | 12 hours ago
you can even use egui with bevy and have an entire game engine.
swiftcoder | 12 hours ago
Indeed, but I specifically don't want an entire game engine. I want a UI with an embedded 3D view.
Dealing with subpar clones of the whole text rendering, IME, and accessibility stacks just to get an embedded 3D view is not worth.
slopinthebag | 10 hours ago
swiftcoder | 8 hours ago
the__alchemist | 8 hours ago
This is what you posted:
> The other issue in this bucket is being able to embed a 3D rendering context into the UI.
Many people pointed out that you have a big selection of tools that can do this.
swiftcoder | 7 hours ago
The vast majority have pointed to tools that do the opposite: they render the UI into my 3D context, not tools that can render my 3D context into their UI.
This is a fundamentally different approach, with significant tradeoffs: you are accepting non-native controls, text layout, IME, accessibility, no direct compositor integration, and re-renders affect the entire UI (not just the 3D viewport).
> I use EGUI + WGPU for a 3D molecule viewer/editor, and it works great
I believe we have chatted about this specific app in some other UI threads on HN, and it looks like a great app, but it's not the sort of data-binding-heavy UI that really stresses a UI toolkit
the__alchemist | 7 hours ago
slopinthebag | 7 hours ago
swiftcoder | 7 hours ago
The browser shell offers a mature text engine, native IME integration, robust accessibility support, access to a wide selection of controls that behave exactly like their native equivalents, and the canvas element is distinct from the rendering model of the surrounding UI elements.
It's not a panacea, but its significantly more advanced than something like egui.
slopinthebag | 7 hours ago
swiftcoder | 5 hours ago
I would rather be doing that, yes. The options to do that without moving all my UI into the 3d context are however slim
gen2brain | 9 hours ago
And of course, no need to use Go, you can use C, there is a nice wrapper for C++. You can also build IUP.xcframework and use Swift if you like, and there is a bindgen example that can generate Lua and Python bindings, or can export API model as JSON so you can generate whatever bindings. Simple C API based on IUP and attributes, but very poverfull. Nice docs and 200+ examples, retained, standard events and callbacks, should be easy to start and fast to build native apps everywhere.
simonask | 12 hours ago
For example, say your UI is drawn with OpenGL, but you need an embedded Vulkan canvas. This takes a huge amount of API-specific code passing API-foreign texture handles and synchronization objects between contexts. You need to do this for every possible combination of APIs, and it's not symmetrical (hosting Vulkan within OpenGL is different from hosting OpenGL within Vulkan).
Every desktop-class rendering API does have extensions for dealing with foreign APIs, but it's a lot of work, to the point where rendering into shared memory from a subprocess is sometimes the most viable option.
swiftcoder | 11 hours ago
See this is high on the list of things I do not want. I don't want my UI rendered from scratch in OpenGL, I want it drawn using the native widget API, which already supports embedding 3D canvases.
This is one of those things that is completely trivial in, say, Cocoa, but arbitrarily hard in most cross-platform UI toolkits.
simonask | 7 hours ago
On a Windows desktop, you have D3D11 and below, D3D12, Vulkan, and OpenGL. I believe you can do most of it if you're using GDI, but even Microsoft's own myriad of UI frameworks have spotty support.
speedstyle | 6 hours ago
ogoffart | 10 hours ago
nicoburns | 8 hours ago
For Dioxus Native, see this example https://github.com/DioxusLabs/blitz/tree/main/examples/wgpu_...
the__alchemist | 8 hours ago
samiv | an hour ago
atillaisik | 11 hours ago
singinwhale | 10 hours ago
jonenst | 7 hours ago
As an industry, I'd rather see 3 healthy competitors rather than 100 or 1. This is obviously not limited to librairies in the rust programming language, and amusingly directly applies to the existing ~100 widespread programming languages.
Not sure how other industries fare on that, the grass is always greener on the other side of the fence.. but it feels like some do better than others. I don't see reinvented 5 wheeled cars every day (although some tech guy just boasted about a flying car recently)
I love the diversity for toys/art/demos/research/... but not so much for industrial work
faceless3 | 6 hours ago
codedokode | 6 hours ago
- first, GPU requires shaders compilation which is slow so you need CPU renderer anyway
- second, not all GPUs are supported, not all have drivers, some are buggy and many machines, like VM, do not have a GPU
- third, it probably uses lot of memory
You don't need a GPU to add one letter to a text field.
I did some tests in a GPU-less VM, using one x86-64 core. The test simply rendered black and white 4K frames. Rendering to memory gave numbers like 360 fps (and ~8GiB/s of RAM writes). Rendering to X server via SHM produced something about 80 fps, the X server used 50% of the core and the program used other 50%. But many users have much smaller screens, and you typically do not need to redraw whole window every frame.
So you can render everything on a CPU and, if the user has a GPU, use it to accelerate drawing rounded rectangles which make probably 90% of GUI.
vinyl7 | 5 hours ago
codedokode | 5 hours ago
The article you are referring to is interesting, but it looks like adding a hack instead of rewriting the code. They also did not make measurements for an older system without a working GPU.
> If rebuilding the UI takes a millisecond at most, how much should we care?
Because user runs multiple programs, and rendering UI doesn't always take milliseconds, and battery capacity is not infinite. Also programs using GPU typically use lot of extra memory, require slow shader compilation, GPUs often have buggy drivers.
Also it would be better if every program used same UI widgets (for example, GTK) rather than have their own set of widgets with missing features like IME support, different hot keys etc.
Also, what is the advantage of immediate mode UI over proper GUI reactive framework with convenient declarative syntax? I see no advantages.
ben-schaaf | 5 hours ago
Shader compilation basically doesn't matter. The number of shaders needed for a GUI toolkit is tiny, and none are particularly complex. In my experience it doesn't appreciably add to the startup time.
I do agree there should still be CPU rendering for when the GPU doesn't work. It's a particularly useful feature for old or virtualised hardware.
codedokode | 5 hours ago
For example, if you are scrolling a PDF you could theoretically "scroll" (change start y offset) of the window buffer, render a newly visible stripe (those 6px) and re-render the toolbar 6px lower which otherwise would scroll with the window.
It seems nobody can do this nowadays, so another option is to use two layers - a document and a toolbar and offload the compositing to window compositor which might as well use GPU for that. So you have one buffer with a toolbar (never changes), and another buffer with a document, and when scrolling, you only draw the changed part and instruct the compositor to draw the document with an offset.
kragen | 4 hours ago
1. With discrete GPUs, which have their own VRAM (unlike integrated GPUs), reading the framebuffer is often much slower than reading main memory.
2. If you're copying pixels around in the framebuffer, the best you can do is memcpy speed, which spends half of the memory bus bandwidth on reading memory. But if you're computing fresh pixels to put in the framebuffer instead, you can go about twice that fast. Sometimes more than twice that fast. As a simple example, https://canonical.org/~kragen/sw/dev3/bgraify.c unpacks 1-bit-deep bitmaps with a palette of two 32-bit colors on one core at 26 gigabytes per second (on this Ryzen 5 3500U), while memcpy() on that same core can only reach about 10 gigabytes per second. (memcpy() on two cores reaches more like 18 gigabytes per second, so the naïve extrapolation is that you ought to be able to hit 36 gigabytes per second for something like a solid-color fill.)
codedokode | 4 hours ago
Also your URL shows 404 for me.
To scroll the content you do not need to copy anything. You can just tell the compositor: "first render rows 6-1000 from this buffer and after that rows 0-5". That would look like the content has scrolled 6px up without a single copied byte. This trick was used by game consoles on 80s.
kragen | 4 hours ago
Yes, you can scroll by telling the GPU to use a different starting address for its framebuffer, but only if you're scrolling the whole screen. If you want to scroll the contents of a browser window but not the browser chrome, though, or one window but not another, you start needing to tell the GPU to composite things from a few different textures, or needing to copy things around in system RAM. If you push this work off on a software compositor like Wayland, you aren't saving any work; you're just changing which process does the work.
codedokode | 3 hours ago
Yes, correct, you need to have two buffers - one for the document, another for the toolbar. In this case you need to do compositing. The good thing is that compositing here is just memcpy, and it can be done on CPU and almost on any GPU starting from 90s, no need for Vulkan support or NVIDIA proprietary driver. And compositing (memcpy) is faster than rendering complicated document from scratch. So instead of sending one large buffer to Wayland, you send two smaller buffers ("send" doesn't imply copying here as Wayland uses shared memory).
So in a perfect world, the application updates a small part of a buffer with a document in a shared memory, changes Y offset, and CPU or GPU rebulds the window that was scrolled by combining the document and toolbar buffers. Oh, even better, by copying only the document part into a framebuffer because toolbar did not change.
So for example, if you are scrolling a text document, with my approach you need to render only one line of text (that became visible) and you reuse previously drawn lines. But with "immediate mode" approach, all visible lines must be re-rendered every frame.
URL works now.
kragen | 3 hours ago
Again, I don't think this is generally true, and that was the specific point I was investigating with bgraify.c. You can potentially render a complicated document from scratch, on the CPU, at speeds closer to memset() than to memcpy(), getting more than a 2× speedup.
And, on the GPU, you can do it at texture-mapping speeds, which are much faster still. (The basic plan is that you put the glyphs of your font into a texture atlas which your fragment shader texture-maps, possibly using SDF thresholding.) rxi's MicroUI https://github.com/rxi/microui is an example of a very small, simple IMGUI library whose standard backend works this way on top of OpenGL.
codedokode | 3 hours ago
And as I have written above, you can offload compositing (memcpy) to any GPU from 90s while rendering letters is a harder task. Even with glyph cache you need to manage it, upload updates to GPU etc. So much easier to not use GPU for this.
kragen | 3 hours ago
Text rendering can be made arbitrarily complex, but in most cases it is not. In Russian, most Spanish, most Japanese, Ukrainian, or English, code points map 1:1 to glyphs, and figuring out where each glyph belongs on a line is a matter of running a prefix sum over their advances. AVX-512 prefix sum on 32-element vectors is about 2 nanoseconds per 32-element vector, so you need about 5 nanoseconds of layout time per line and about 200 nanoseconds for the whole screen, say 250ns to include the time to check for exceptional cases and figure out where each line belongs on the screen. This gives you a display list of some 3000 glyphs at various places on the screen.
If you rerender 2 megapixels from that display list at, say, 5 gigapixels per second on the CPU, it's going to take 400μs, which is 400,000ns. (I think the evidence I've shown above strongly suggests that this is doable on my laptop here, although it isn't a proof.)
If, instead, you copy 2 megapixels from one place to another in RAM, you can only do that at about 2.5 gigapixels per second, so reusing previously rendered lines will take more like 800μs.
That is slower than 400μs.
It is not faster than 400μs.
If you, instead, pass the display list to the GPU to texture-map from the font atlas, well, this GPU has a theoretical peak texture fill rate of 38.4 gigatexels per second, so it will take more like 52 μs. On the GPU, you can't really reuse the previously rendered lines.
Again, 800μs is slower than 52 μs. It's not faster.
The GPU doesn't really mind rendering 3000 quads instead of two or three. The difference is down in the range of [correction!] microseconds; this GPU can in theory do one triangle per clock at 1.2GHz, so each quad takes about 1.7 nanoseconds, and you can do 3000 of them in 5μs, about 10% of the total. But this is running concurrently with the fill rate, so it doesn't increase the 52μs.
The key thing to note, though, is that even the 800μs you would get by foolishly reusing previously rendered lines is still pretty small compared to the frame time, which at 60fps (what my laptop can actually run at) is 16667μs, 20 times longer. If you parcel that out among the 3000 or so glyphs on the screen, you have almost 5.6μs to do all the text layout calculations for each glyph: kerning, ligatures, shaping, whatever.
It's true that you need to manage the texture atlas, glyph cache, etc., although multichannel SDF fonts can provide reasonable antialiased results at a fairly wide range of pixel sizes, which can reduce this load quite a lot.
codedokode | 2 hours ago
First, the data is sent to the monitor from a framebuffer. With compositors like Wayland, every window has its own buffer, and when it is damaged (updated), the compositors copies (memcpy) the damaged part from window buffer into the framebuffer using CPU or GPU. As I understand, this part cannot be skipped and the application renders window content into a window buffer so there always will be a memcpy stage to have it actually displayed.
For example, if the button changed its color, the program updates button image in window buffer, reports the damaged rectangle and the compositor copies that change into the framebuffer to become visible.
Actually compositors use two buffers to prevent tearing, and switch between them on every update so the things might be more complicated.
So with this model in mind, updating one line of text in a window buffer is faster than updating the whole buffer.
Furthermore, to render the text you need to memcpy the glyphs from glyph cache into their locations. So rendering whole window of text boils down to lot of small memcpys.
Also, you mention AVX-512 but I don't think my CPU has it. And when doing lot of 256-bit SIMD the CPU starts throttling to 1GHz-level speed. Also, you mentioned display lists but that requires extra memory compared to my approach.
Also, I decided to try to actually benchmark rendering text from a glyph atlas. Luckily, LLMs can write such code in matter of minutes, so I wrote it: https://pastebin.com/7baP4tWv
Results in a VM without a GPU:
Buffer 3840 x 2160 px, grid 295 cols x 90 rows = 26550 letters/frame, 10 runs, avg per frame: 7.832 ms, time per letter: 295.0 ns, letters/second: 3390088, pixels/second: 1059.086 Mpx/s.
I also godbolt'ed the hot loop in case you are curious about the assembly - it seems to use 128-bit SIMD and unrolled the single glyph rendering loop: https://godbolt.org/z/1Gh1McKE8
kragen | an hour ago
kragen | 4 hours ago
(If you're mostly memcpying from a font that fits in cache, you should get a higher fill rate than this.)
Using a GPU is of course much better, but not necessary to reach the level of performance you're talking about.
kragen | 4 hours ago
If you're concerned about efficiency, GPU support is very important. But IMGUI is not the efficiency enemy you think it is; while IMGUI libraries do need to traverse the hierarchy of visible objects on every mouse movement, there are generally only a few dozen rectangles and a few thousand letters and other graphical objects visible, so the work involved in traversing them is generally very small amount compared to copying a few million pixels into the framebuffer.
As an example, I currently have a browser viewing HN and an Emacs window open, and they total about 3000 characters (1523 mostly-blank characters and 206 words in Emacs, 335 words in HN, plus chrome), a couple dozen icons, and another dozen or so roundrects. But my screen is 2 million pixels.
So the amount of per-drawable work has to be almost three orders of magnitude larger before the per-pixel work isn't the dominant factor.
IMGUI libraries do have to do a bit more work to avoid redrawing all those pixels on every mouse movement, but many popular IMGUI libraries, such as React, do in fact do that work. It's a somewhat less simple job than for retained-mode GUI libraries like Qt (or the browser DOM), but the added complexity in the IMGUI library often pays off in simpler and more reliable apps.
codedokode | 4 hours ago
Only in a hello world application. Every professional editor like GIMP has tons of tiny widgets. And redrawing one tiny widget on mouse over is faster than running the render function.
Also, you are assuming that running render function costs nothing while in real-world apps there will be layout calculations (because you don't want to position widgets manually), array iteration (for example, to display a sum and average of values from a 100K element array), text characters layout, calling helper functions, generating SVG for a 10K points graph, some genius might add reading from a file, etc.
Yes, writing good code is harder than bad code, especially for a LLM.
And if you are on the stage where you need widgets and layout calculation, why not add a dirty flag and damage rectangles as well, I cannot understand.
kragen | 4 hours ago
You say I'm assuming that the render function costs nothing. I thought it was clear that I was not assuming that; what I said in the comment that you're responding to is, "The amount of per-drawable work has to be almost three orders of magnitude larger before the per-pixel work isn't the dominant factor." But you may have responded before I added that; I forget if I added it in later. Here by "drawable" I mean talking about things like letters, not widgets that have their own render functions. Widgets that have their own render functions can take more than four orders of magnitude more time than the per-pixel work before the per-widget work becomes the dominant factor.
It's true, as you say, that people are capable of using up that margin by doing things like reading from a file, because writing good code is harder than writing bad code. But that's not really a question of immediate-mode vs. retained-mode. You can write bad code with retained-mode GUI libraries, too. In fact, my experience is that it's much harder to write good code with retained-mode GUI libraries.
As for layout calculations, the layout engine I elicited from Opus 5.5 for http://canonical.org/~kragen/sw/megilloom-sandbox lays out 60,000 lines of text per second, in JavaScript, and it supports table layout. (It caches the layout calculations so that it can remain responsive up to hundreds of thousands of lines.)
Some IMGUI libraries are capable of providing a dirty flag and damage rectangles without requiring every application to duplicate the error-prone cache-invalidation logic to do that. As Raph points out in this post, they're not a panacea. But they're not as bad as you are naïvely assuming them to be.
codedokode | 4 hours ago
Because writing good code is harder than bad code.
Let me give an example. I vide-coded a program that renders white and gray frames and it can do it faster than 60fps on one core in a VM with no GPU. However, VS Code in that VM feels like it is running at 5 fps. The scrolling is slow and laggy. Why is that so? Probably because writing good code is harder. And probably they were thinking like you, that redrawing the whole screen is fast enough except in fact it is not.
Every time someone says that their framework is fast, they should test it in a VM without a GPU.
kragen | 4 hours ago
I think VS Code is slow because it's a piece of shit, not because it uses an IMGUI library. I don't think it does use an IMGUI library; I think it uses src/vs/base/browser/ui which is all retained-mode.
VS Code runs in Node, which is fundamentally mostly a single-event-loop system, and in general it's very difficult for large single-event-loop systems to be reliably responsive, because literally any loop, anywhere in the system, that runs for too many iterations, will cause it to start janking. That's a problem with browser apps, too. Erlang-style actor systems have a much better chance, but they can still run into unexpected head-of-line blocking problems.
I have some experimental designs for software transactional memory systems which I hope will solve this problem...
codedokode | 3 hours ago
bluegatty | 3 hours ago
AI is not a magic pill - it makes Rust more accessible, but the inherent complexity remains.
The AI reasons better with other languages for the same reason that humans - there's less to think about.
The added 'structure' of Rust is does not improve the coherence of the logic of the problem space aka it does not solve the problem of what goes in where bank account or what goes where on someone's screen - it solves the problem of 'what goes where and for how long in cpu memory and what can access it'.
Rust helps to solve implementation issues not user-problem issues.
By all means - have fun with this stuff, experimenting and hacking is fun, but it's definitely swimming upstream.
If you goal is to make a nice, clean UX platform in the age of AI you probably would not choose rust - unless you're 'start with Rust and work backwards' ...
It's 'very good for what it's good for' ... not so much other things.
aatd86 | 3 hours ago
glennfiedler | 3 hours ago
It's much faster than the Rust-based UI systems out there and basically is an entire web stack / electron replacement in C++.
So maybe take a look and see if it's helpful for your UI if you are creating an app now with AI coding:
https://github.com/pdoane/prax (Apache 2, MIT)
bonki | 2 hours ago
pdoane | 2 hours ago
dabinat | 2 hours ago
But one thing that’s great about coding agents is that they make technical debt much less of a problem. So you can freely pick a framework and if it ends up being a bad idea, it’s no big deal to switch to something else.
logicalshift | an hour ago
What I hit early on with this project is that Rust's ecosystem is very dynamic and whatever I picked wouldn't be current later on and I'd need to replace it. So that's the problem I worked on solving, and I think it's produced something quite interesting.
Core idea is to communicate using streams and not function calls, because you can replace the receiver or map streams to new streams when an API changes. `flo_scene` is the crate I came up with to implement this. It's sort of an actors framework but as it's more to achieve specific goals than implement the theoretical idea of what an actors framework should be it's got its own names for things.
flo_scene divides up large software into 'sub-programs' that talk by sending messages. The dependencies are all defined externally which makes a huge difference to how complexity evolves as software grows: a sub-program that wants to draw something just sends drawing requests without needing to know exactly what or how those requests are realised later on. Similar for displaying a UI: it's just messages that something else handles so replacing the backend is surprisingly easy.
Eg: the old version of FlowBetween can switch between a web app and a Mac OS native app just by changing where it sends the UI messages to: it's a really effective approach at making it so dependencies are always shallow and easy to replace no matter how much stuff is built around them. It can run as both at once too (even weird stuff like mirroring your desktop session as a fully HTML web app), which I think is an entirely unique capability.
Then there's flo_draw which is the rendering library I came up with. This has the same non-monolithic approach to rendering graphics, which lets you do some neat things. One is the very straightforward initialisation it has if you just need a window to draw in (I kind of wanted to get to the point where you could draw stuff the same way you can println stuff but some UI frameworks see the main thread as 'special' so that's not possible) The other is how it lets you compose multiple sources into a single drawing: it has namespaces so that resources can be loaded without conflicting with each other. It has layers so it's possible to combine the output of many sources into a single output. As everything is a stream you can use it as an immediate mode or a retained mode renderer: because it has layers you can do both at once. Last thing it has at a high level are sprites, which are a way to repeatedly render a set of instructions - a modernised version of the old concept - and thus are a generalised composition mechanism.
mpweiher | 31 minutes ago
[...]
So maybe the classical GUI libraries that had mixed-mode (retained + immediate) as required weren't so dumb after all?