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.
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.
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!)
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.
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.
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.
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.
> 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...
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.
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.
Using a GPU is of course much better, but not necessary to reach the level of performance you're talking about.
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.
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.
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.
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.
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)
"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 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.
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.)
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.
> 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.
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.
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.
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.
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 :)
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.
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.
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
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).
> 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.
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.
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.
> 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.
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.
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.
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.
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.
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.
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.
> It's written by a team of funded ex-Qt alumni, is incredibly fast
I don’t know how you define fast, but slint is incredibly resource hungry on desktop.
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
> and even 70 MB is not particularly resource-hungry compared to other UI frameworks, especially browser-based ones
Is it? A comparable Electron hello world app is ~80-100 MBs
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.
Agreed. And it bundles the entirety of Chromium engine.
And how much for an actual useful 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."
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
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.
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.
Small correction: Slint is free for proprietary desktop, mobile and web apps under our Royalty-free license, regardless of company size.
I'm working at Slint.
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!)
The recent supply chain security disaster (with no end in sight) digs this moat even deeper in my opinion.
That is where the "provide non GUI lib services" mentioned by Onavo comes in. Have you thought about that?
> by just straight up using skia
I think building up on wgpu is better
> https://github.com/DioxusLabs/anyrender
I have an abstraction which allows you to switch between the 2 (and CPU rendering options) at build time.
wgpu is unusable without a modern GPU, unlike skia.
If you mean "modern" as in from within the last 15-20 years then yes. It targets both WebGL2 and OpenGL, in addition to Metal and Vulkan.
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.
[1] https://nsh.dev/ [2] https://github.com/longbridge/nsh/commits/main [3] https://nsh.dev/elements/
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.
[1] https://daybrite.dev/showcase/ [2] https://news.ycombinator.com/item?id=49261607
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.
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??
Extremely sloppy, especially the click sound on some of the pages. And the "App Stories" don't help to promote it either.
However, the project seems curious still. I see using it for some fast prototyping.
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.
[1] https://github.com/longbridge/nsh/commit/70a45b59ea5813bbc5f...
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.
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.
> 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.
> there are generally only a few dozen rectangles
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.
> the error-prone cache-invalidation logic
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...
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.
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.
Using a GPU is of course much better, but not necessary to reach the level of performance you're talking about.
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.
URL works now.
Immediate mode UIs don't need to be redrawn on every mouse move: https://blickeditor.com/blog/caching-an-immediate-mode-ui?la...
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.
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.
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.
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)
> Immediate vs retained mode
> 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.
but are they power-efficient?
"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 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.
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.)
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.
> 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.
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.
For Dioxus Native, see this example https://github.com/DioxusLabs/blitz/tree/main/examples/wgpu_...
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.
Windows users do not want you to use the system API (indeed most preinstalled apps don't) and Linux users don't have one.
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.
EGUI + WGPU works well.
the frameworks with wgpu backends can do this pretty trivially.
you can even use egui with bevy and have an entire game engine.
> you can even use egui with bevy and have an entire game engine.
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.
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.
well like i said, you can use something like egui's wgpu backend (which is the default) and draw whatever 2d or 3d graphics you want.
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
Ah got it; I appreciate the clarification. That was indeed the part I'd missed.
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 :)
> i thought we were talking about embedding 3d context into rust u
I would rather be doing that, yes. The options to do that without moving all my UI into the 3d context are however slim
I just use Flutter for the UI and then use https://cjycode.com/flutter_rust_bridge/
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.
Bridges give me bad memories of React Native. There's a reason why they moved away from that - it was terrible for performance.
Or do as Mitcad does: use C++ to talk to Qt, and do the rest in Rust.
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.
https://www.youtube.com/watch?v=Bo-vESS4jt0
Yeah, I don't get it. What is wrong with Qt plus Rust bindings? At this point, is there a more mature cross-platform GUI toolkit?
The traditional model of mutable trees of objects that use heavy inheritance is a rough fit for Rust.
Or Ladybird. Yes, I know, the maintainer it's a jerk but the software it's fine.
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
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.
>Windows still has no clear native choice
Wait, where did MFC go?
EDIT: https://zendevy.com/en/tech/mfc-history-and-current-status-2...
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).
Nice article, thank you for sharing it.
I do want to nitpick this part however:
> That’s been playing out architecturally in the choice between immediate mode and retained mode. Immediate mode is very appealing because it’s less total code and seems quite a bit simpler. And for some applications (most especially development support for games) it works well. However, I am concerned it won’t scale especially well. In short, it’s good at the first 90%, but it makes the second 90% harder. To be considered really production-ready, it has to establish stable widget identities to build and update the accessibility tree, and it has to reliably cache expensive intermediate artifacts such as text layouts (simple immediate mode often gets around this by cutting corners in text layout, which may be fine for gamedev). And of course, it pulls strongly towards a model of re-rendering everything every frame rather than exploiting layers in the compositor.
It's a common criticism but I don't think it's based on anything other than preconceived notions about rendering being slow and doing a ton of caching makes everything faster. but neither seem to be backed up by any sort of empirical evidence. Anecdotally every imgui I've used has been lightening fast, and retained mode UI's like the browser, windows software, new Macos apps written in SwiftUI, etc, have performance problems.
Egui has solved the accessibility problem and does a lot of caching: galleys, glyphs, and layouts are cached, packed texture atlases minimize GPU uploads, and it uses inputs & animation state to draw on demand.
I also don't see how retained mode UI would scale better. Retained mode UI's are typically slow - they have a complex multi-pass general layout system and a ton of bookkeeping, which is why you typically need to keep updates to a minimum and ever-more-complex change tracking systems are being built to reduce updates to a minimum. This doesn't scream scalability to me - whereas in an imgui there is a baseline overhead but adding more widgets or more frequent updates have a negligible performance impact. the worst case for retained mode is a UI which has many widgets frequently updating multiple times a second, which means you approach the update and drawing of imgui but with the additional overhead of the change tracking, bookkeeping, etc of the retained system.
Also there is nothing fundamental about imgui layout systems being limited, and in my experience it's not that difficult to build custom widgets to implement pretty much anything. Retained mode layout systems are usually declarative, where you describe a layout and hope that the system is flexible enough to support what you want, whereas with an imgui you can just directly draw and shade geometry to get whatever you want.
Otherwise, great article and I look forward to the future of Rust UI.
Thanks.
The point I'm making is a subtle one. I do think you can go very far with an immediate mode GUI paradigm, and it's also certainly the case that most of the imguis you see are performant. But I still wouldn't choose it for a design or productivity app.
Once you do all the caching of text layouts and building of intermediate trees for a11y, you no longer have a pure imgui, but rather a hybrid.
I'm going to try to get this point across in an analogy, apologies to people not familiar with the referent.
Let's say you're frustrated with the size and complexity of a modern C compiler like clang or gcc, and want to do something simpler. One of the design decisions is whether use SSA (static single assignment) as the basis for the intermediate representation. If you're going for simplicity, you might quite reasonably choose to skip it; you can generate reasonably good code straight from the AST.
But then, you and your users get dissatisfied with merely reasonably good code, and want some of those optimizations that make production compilers generate actually fast code – constant folding, common subexpression elimination, strength reduction, etc. You can certainly implement them as AST transforms, but it gets difficult to track everything? You add a bunch of logic and eventually get those optimizations to work about as well as the SSA-based version in real compilers.
Another compiler designer has similar goals but uses a different strategy: dive in and do SSA from the beginning, which is not as simple at first, but then you can just do those optimizations "from the book," without a lot of friction.
Basically what I'm saying is that I prefer the second compiler. It's not to say the first can't be made to work.
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
https://www.forrestthewoods.com/blog/proving-immediate-mode-...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.
Egui solving accessibility is news to me. Has something changed in the last year or two?
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.
> Absolute nonsense.
How so?
I quite like the Crux approach which uses native UI (mobile, desktop as well) as well as Iced for desktop/web, both of which use the Elm architecture.
> 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.
Thanks for the knowladge guys, thats ball knowladge!
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.
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.
Given the price of RAM, I'd say it's nice to think about performance?
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.
> e.g. C++, ObjC, 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.
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.
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.
we've been circle jerking ever since win32 and vb6.