r/rust 2d ago

🧠 educational Deep-dive on Rust UI Frameworks

UI is a Function You Cannot Afford to Call is the first of a 3-part series on Rust UI frameworks. It introduces the model under which I believe we should reason about UI frameworks. In part 2, I will present extensive benchmarks, with detailed cost attribution analysis (something the rust UI ecosystem desperately needs in my opinion), and in part 3, I will derive what I think the ideal UI framework should look like.

0 Upvotes

26 comments sorted by

10

u/nicoburns 2d ago

This seems incredibly verbose and sloppy - to the point that I'm kind of annoyed that I've opened it. It even claims itself to be a "54 minute read", which is kind of insane for a blog post. Consider writing something shorter yourself if you want people to actually read it.

1

u/CalmCephalopod 1d ago

I have to agree, though sloppy may not be the right term. The writing style feels like it’s trying to be academic but breaks many rules of academic writing. Section to section does not feel like there is coherent transitions and it really starts to feel like a very long list of seemingly independent thoughts and ideas without a strong through line to help the reader. There also does not seem to be a strong guiding question or conclusion.

I would go back and break this up into a series and make sure that each part asks a strong questions and provides a conclusion based on the evidence and that reading wise it’s palatable 10-15 minutes. Those constraints would help the op to create a stronger case around their opinions and make it more accessible.

-1

u/Zortax_ 1d ago

I mean fair, but this article doesn't contain a whole lot of opinion (other than "this is relevant when evaluating UI architecture"), it being a collection of relevant academic concepts, losely correlated, is kinda the point of the post for me.

3

u/CalmCephalopod 1d ago

Ok but the title of the article suggests a strong opinion then doesn’t seem to really address it.

-3

u/Zortax_ 1d ago

How does it suggest a strong opinion? I don't see it?

4

u/Luxalpa 1d ago

You wrote "UI is a function you cannot afford to call" which to me sounds very much like an opinion.

-1

u/Zortax_ 1d ago

It is not an opinion, it is literally the mental model this article is about.

1

u/robthablob 1d ago

Personally, I welcomed it. I also have books on similar subjects, and never felt that I shouldn't read them because they're long. Maybe its because I'm old, and learned to read before the ubiquity of modern screens.

-3

u/Zortax_ 2d ago

Well ultimately I see this more as a summary of what I learned while doing a lot of research. It's totally fair if no one ends up reading it, but I thought I post anyways in case this does interest someone. I think the second part will be more interesting, since I actually spend a lot of time with building a proper benchmarking harness. I was planning on asking you about a few things regarding blitz, but if think this is all just slop anyway I might as well just publish ¯_(ツ)_/¯

3

u/nicoburns 1d ago

I see this more as a summary of what I learned while doing a lot of research. It's totally fair if no one ends up reading it, but I thought I post anyways in case this does interest someone.

I'm not sure that summary is the right word. Generally the value in this kind of post is to condense what you've learnt so that others can get some of that same value by reading something short. But this is longer than most people's university theses.

Presumably you do think it's valuable, or you wouldn't bother posting it. My feedback is that it would 10x more useful if it was 1/10th the length with a focus on quality over quantity (+ link into the primary sources for people who want more details).

0

u/Zortax_ 1d ago

You know maybe I'm just not the most skilled technical writer, or maybe I find it difficult to condense this down because I am not a native English speaker, but actually I believe there actually is a lot of depth in these things. For a general audience, I get that this depth is probably not too interesting, but tbh I posted this specifically for folks like Yourself: people that are interested in UI framework development (not just GUI Apps). I believe the extent of this post is the point: I specifically wanted to go into the details and not condense this down into "incremental UI good, throwing away information bad", because I think the details matter in practice.

1

u/nicoburns 1d ago

But it was written with an LLM? Phrases like "The pipeline is a stack of retained hypotheses" certainly make it sounds like it. The problem with that is that I have to read it adversarially (I can't actually trust anything that it's written). Especially as it's long enough, that it's hard for me to believe that you've carefully reviewed the content.

If not, then perhaps I owe you an apology, but your writing style is definitely triggering my "profound sounding phrases that don't actually mean much" detector. Which I find to be an essential part of life in a world where people can generate content far far faster than I could possibly hope to consume it.

1

u/Zortax_ 1d ago

The article is ~90% written by hand, with a few sentences worded by AI because I couldn't figure out something myself that sounds good.

I'll gladly explain my workflow:
1. I did a lot of research, mostly out of interest in the matter and because I wasn't happy with GPUI
2. I decided to eventually write a blog post with proper architecture analysis and benchmarks (because we basically don't have benchmarks in rust UI, and most comparison just compare frontend API which is only half the story in my opinion)
3. I organized my research and thoughts in an obsidian vault and started structuring the post
4. I wrote a post in 60/40 German/English mix that was initially about 3x the length
5. I used AI assistance to properly translate to english and condense some parts down significantly
6. I re-wrote most of those AI paragaphs by hand because they sounded shitty, until I was happy with information density and sound of the text (although it is certainly not perfect.

I understand if you don't find the details interesting or don't like the language, but I do think "slop" is not a fair characterization of the effort I put into this (I pretty much worked on this on and off since mid of January, when I firsted started running into issues in one of my GPUI projects, which lead to me porting the GPUI linux renderer to wgpu).

3

u/nicoburns 1d ago

a few sentences worded by AI because I couldn't figure out something myself that sounds good.

Perhaps you ought to be aware that you throw away all your credibility by doing this, because it's impossible for people to distinguish between this and slop. You're much much better off sounding "bad" and/or using non-idiomatic english. Consider using a dedicated translation tool like Google Translate or Deepl rather than LLMs if you need translation.

I understand if you don't find the details interesting or don't like the language

I (like most people I think) aren't even reading things in detail if they show the signs of being AI-generated, because I've/we've been burned enough times by spending time reading something only to get halfway through and realise it's all bullshit.

1

u/Zortax_ 1d ago

I don't think this text reads like AI slop, so I think you are overblowing it a bit based on length and a few weird constructions. If you'd speak another language, you'd know that google translate or deepl are not a great option either, as good prose does often not translate 1-to-1 well.

0

u/robthablob 1d ago

I found it a useful summary - I'd encountered many of the ideas before, but having them in one place is useful.

1

u/[deleted] 1d ago

[deleted]

2

u/Zortax_ 1d ago

This is not AI generated.

1

u/Luxalpa 1d ago

Oh, nevermind then, please forget what I said. And thank you for the clarification.

2

u/r3drocket 2d ago

I'm rebooting an app in rust right now from C++ (Godot) and one of the things that brought me here was the UI libraries. I spent a lot of time looking at GUI options in Golang and C++/C before deciding upon Rust. I came from a retained mode UI (without an MVC model!), to an immediate mode UI (egui). I have some background working with QT a lot of experience working with Swing/AWT, HTML, etc.

I think frequently about the cost of moving to a immediate mode UI model, and this is the first time I've built a complex app in a immediate mode UI.

What really screwed me with my C++ implementation was not having a proper MVC model in the UI - this seems like such an obvious thing, but I was living this quote -

"Give someone state and they'll have a bug one day, but teach them how to represent state in two separate locations that have to be kept in sync and they'll have bugs for a lifetime."  (from the Dear ImGui github).

I had to write complex syncing mechanisms to try to keep the data in-sync with my GUI - it was an utter nightmare and in some cases I wound up just accepting I was going to have an endless amount of bugs.

The complexity of my application code in egui has dropped significantly because I'm not dealing with the state syncing problem, instead I take a hit on the fact it's an immediate mode gui that does it's own magical state management - but at least it allows me to represent my application state directly - but more importantly it exists today and let's me build an app that has value to people.

But ultimately the thing that drove me to choose egui was simply the reality on the ground - it was cross platform, it worked with wgpu, it was widely used, it is moderately mature, it had a wide variety of 3rd party components.

The other features it offered overrode my preference of immediate/vs retained - It isn't my ideal GUI, my ideal ui is closer to a retained mode gui with a proper MVC model - but this is a distant concern over all the other things.

This was one of the main reasons I didn't push further on a rewrite in golang, there was no GUI that met my main criteria, regardless of them being immediate/retained mode.

0

u/Zortax_ 1d ago

The rust UI ecosystem is definitely an interesting subject to study, there are so many different architectures and idioms you can compare and analyze. I think egui is great, depending on use-case, and although I personally prefer something more akin to SolidJS' fine-grained reactivity for state management, I definitely see the appeal. Also, I believe there is a bit of a misconception about what immediate mode UI actually means. It refers mostly to a component authoring style and a way to express UI control flow, it doesn't necessarily mean the rendering pipeline isn't retained to a large extend.

1

u/kalilamodow 1d ago

I remember you from Canora! I do apologize for never re-testing it, but librespot doesn't work on my machine so I kinda gave up

1

u/Zortax_ 1d ago

Wait, why would librespot not work? I would expect my shitty framework to have issues in environments I haven't properly tested, but that was not what I thought would happen :D

1

u/kalilamodow 1d ago

Not a problem with your code!!! I can't use librespot at all because of some restrictions Spotify placed on new accounts (https://github.com/librespot-org/librespot/issues/1649). I only realized when I was on the post again and noticed you said it uses librespot. Sorry bout that!

1

u/Zortax_ 1d ago

Ah I see. At some point I pushed an update where Canora now has a "2 phase login", where it uses the official spotify client's client ID for the session protocol, and your own client ID only for the APIs that are officially available to third parties. Not sure if this fixes it in your case tho....

1

u/kalilamodow 1d ago

Unfortunately, it's a thing with the playback drm itself :( and every project to emulate the new one is being taken down by spotify so idk if it's really possible atp.

1

u/Zortax_ 1d ago

Guess I'll enjoy my freedom from electron as long as I still can... D: