by RustSupremacist · 1y ago · 0 comments
Rust is simply not meant for GUI-based data design but I still want Qt in Rust. That's it. Not QML or Slint. No markup at all. None of the immediate mode things. No other languages. Definitely not GTK. I'm worried it will never happen for Rust and it will be such a missed opportunity.
Every GUI I replace with a TUI is one less flow-breaking obstacle where I have to suddenly reach for the mouse.
1. Consistent font and sizing. Pick the font you find easiest to read and set it in the terminal, now all TUI apps use it at the correct size.
2. Consistent theming. TUI apps use the same color scheme as your terminal, as your vim, etc. A consistent "desktop" is less distracting. Especially when you don't have to deal with crappy Electron apps displaying animations and ads (looking at you Discord).
3. Efficient on screen real-estate. Most TUI apps don't waste a lot of space on "padding", "giving elements space to breathe" or other "correct UX patterns". They tile nicely.
4. Never and issues copy and pasting. I used a GUI chat app recently that wouldn't let me select text, seriously.
5. Did I mention they are fun to use and relatively easy to develop?
And copy / paste, "hm does this TUI intercept mouse clicks, ah it does, oh what was the key combo for my terminal emulator that allows to skip that? Crap I pressed ctrl-c instead of ctrl-shift-c". Or worse when you want to select text in a column-based TUI and your terminal emulator doesn't have any sort of column-selection handling.
By default, TUIs have bad discoverability unless the developer puts in the effort. But at least you have keyboard navigation and run in a terminal.
By default, GUIs have bad keybindings unless the developer puts in the effort. In the worst case they aren't even kb navigable. But at least they tend to be discoverable.
TUIs have to be navigable by keyboard. They could be garbage in every other way, but at least they have that.
GUIs might have keybindings as polish if the developers put in the effort. Otherwise they either don't have keybindings, or they rely on generalized keybindings that come with the OS/UI toolkit that can be bad/impossible in arbitrary ways, like if tab is swallowed by an input so you can't even tab past a component or dismiss a modal. Or the only GUI is inside a web browser.
I am building tooling around "Verifiable Credentials" (the W3C standard, OpenID standard, and all the standards around and below it).
So me and my co-workers need tools to check JWTs, resolve DIDs, generate Proof of Possession, .well-known contents and services discovery, do OpenId Connect flows, interpret "offer requests", "presentation requests", QR-codes, etc. It started as a bucket of random commandline things that random devs whipped up when needed (in typescript, python, bash, rust, some PHP), and now slowly consolidated into a consistent "toolkit". I am currently still porting most of these tools to Rust and make their CLI interface and IO consistent.
But from there I'll be adding a TUI very quickly.
By no means meant as "end-user" software - those exist and called "wallets". But for developers and devops working in this niche. These don't need a GUI. I'd even wager these users don't want a GUI but prefer a TUI, but in any case, the TUI is just so much easier and more accessible for me as a dev that it's the choice between a TUI+CLI or no UI, just CLI.
I think writing a useful GUI has considerable overhead no matter which technology you use. In addition they cause other difficulties, like testability, i18n, l10n and accessability.
This is why people often resort to command line tools, rightfully so. There are cases, however, where a CLI won't cut it and I believe TUI's are a nice and lean solution that sits right between CLI and full-blown GUI and isn't going anywhere.
There's no standard to communicate TUI semantics to assistive technology, and whatever few standards actually exist (like using the cursor to navigate menus instead of some custom highlight) aren't followed.
With GUIs, those standards exist, and are at least somewhat implemented by all major (non-Rust)UI frameworks.
What’s actually hard with screen readers isn’t getting text (that’s been easy on most GUI systems for decades) but communicating things in the right order, removing the need to see spatial relationships or color to understand what’s going on.
TUIs make that harder for everything beyond mid-20th century-style prompt / response interfaces because you don’t want to have to reread the entire screen every time a character changes (and some changes like a clock updating might need to be ignored) so you want to present updates in a logical order and also need to come up with text alternatives to ASCII art. For example, if I made a tool which shows server response times graphically a screen reader user might not want to hear an update every second and if the most interesting thing was something like a histogram I might need to think about how to communicate the distribution which is better than rereading a chart every second only to say that the previous one has shifted to the left by one unit and a single new data point has been added.
Those are non-trivial problems in any case but they’re all harder with a TUI because you’re starting with less convention and without the libraries which GUI interface developers have to communicate lots of context to a screen reader.
Most TUIs don’t have these either. So I don’t see this as a difference between TUI/GUI. If you want to make a GUI and want to ignore these things, you are free to do so.
An old school DOS TUI reads keyboard input one character at a time from a buffer, doesn't clear the buffer in between screens, and is ideally laid out such that a good part of the input is guaranteed to be fixed for a given operation. They also were built without mouse usage.
So an operator can hammer out a sequence like "ArrowDown, ArrowDown, ENTER, Y, ENTER, John Smith, ENTER" and even if the system is too slow to keep up with the input, it still works perfectly.
Modern GUIs almost never make this work near as well. You need to reach for the mouse, input during delays gets lost, the UI may not be perfectly predictable, sometimes the UI may even shift around while things are loading. Then also neither does Linux, I find that the user experience on DOS was far better than with ncurses apps that have all kinds of weirdness.
I find egui far easier than Ratatui.
I have to agree with this, but for a lot of different things other than GUI as well. My friends all want me to use Rust, but I moved back to C++ after trying to do a lot of different projects in it after finding every crate I needed to be a WIP or abandoned state. There are the massive crates that are super popular of course, but it seems that once you get off the popular beaten path the available crates becomes far worse than any other language I have ever used.
Of course comparing Rust to something like Python or C++ is unfair to Rust, since Rust has had less time to develop those packages, but I think its more about the community at this point. I just don't see any enthusiasm for working on crates/frameworks. Most of the time when I find a crate I need, its sitting at version 0.3.0, last updated 1-3 years ago, with the documentation simply stating "Reimplementation of X in Rust, go read X's C++ documentation on how to use."
GUI is kind of unique because it's a really hard problem - both a ton of work and also a bit awkward to make ergonomic in Rust.
> last updated 1-3 years ago
That's way too low a bar. I bet most of these niche C libraries that don't have Rust equivalents are similarly slow-moving.
GNU Make regularly goes 4 years without a release but it's still alive.
Which is great, Zed's stack is pretty damn good. But like anything not yet widely used outside of its original use case, it can be rough around the edges, and just plain doesn't support anything that is not needed by Zed.
I'm betting on Slint. I kind of hated QML but it looks like they have learned a lot of lessons.
I really want to love gpui and would like to avoid using webviews, the advantage of web-based apps is that accessibility is (relatively) easy to do if you’re attentive to it. At the time I looked at it, gpui did not support screen readers etc at all.
I suppose I understand why they made that decision given their business priorities, but it’s hard for me to tell my vision-impaired friends and colleagues that there’s literally no way for them to use my app.
> Inspired by the gaming world, we realized that the only way to achieve the performance we needed was to build our own UI framework: GPUI. [0]
GPUI is not widely used because they only recently started publishing in crates.io [1] and still AFAIK their documentation is not that great yet, I suppose people will start using soon enough it, I was thinking on using it over Iced that was the other GUI that I feel that have future (because it's used by Cosmic Desktop).
[0] https://zed.dev/blog/videogame [1] https://crates.io/crates/gpui/versions
https://github.com/zed-industries/zed/tree/main/crates/gpui
See the discussion on a collection of elements ontop
// Vidrun, born of the sea-wind through the spruce
// Vidrun, green-tinged offshoot of my bough, joy and burden of my life
// Vidrun, fierce and clever, may our clan’s wisdom be yours:
//
// Never read Hacker News
// - Aphyr, "Hexing the technical interview"
if (document.referrer.startsWith("https://news.ycombinator.com")) {
document.location = "https://upload.wikimedia.org/wikipedia/commons/d/d4/Human_fart.wav"
}
> https://www.boringcactus.com/assets/site.js"I like the A tool in category B. System C doesn't have tool A; system C is dreadful in category B".
I think you could have made the acute part of this argument about GUIs in rust 3 years ago, but not today!
I need to try Slint and GPGUI. I love EGUI, but need to do a proper comparison; could be missing out. This seems to be a concern of a different nature from the one you describe!
It's no less or more equipped than C or C++, so not really sure what to make of this comment given the username lol.
My reference in this are Delphi .dfm files, which you rarely have to edit manually because they're handled by the IDE form builder. It is still a fantastic IDE to build native UI apps and I don't see a reason why Rust couldn't be used the same way.
In the linked article the author had trouble building Qt for windows and because they wanted to go through 40+ GUI libraries they skipped it instead of pushing through. That's why it doesn't show up in final short-list of good options.
In my books (writing Rust since 2013, but haven't done any GUI work in it), Qt and Slint are the best options out there.
It made the post more amusing, actually. I sighed when I saw "Windows Narrator" suddenly.
Because it is quite easy to do.
There are also TUIs in other languages, just Rust is more cool.
This topic comes up often, so I wrote a blog post explaining why I think a DSL is a good fit: https://slint.dev/blog/domain-specific-language-vs-imperativ...
Whereas when kovid made the kitty terminal protocol, it got implemented by the next 3 or so new terminal emulators. You don't get this kind of modernization from any other UI solution save browsers. And no way do I want to do web development for my own stuff. I suppose I could target Dillo or something like Servo, but I'd be more inclined to consume the base X11 protocol, as Vidar H did.
My Ruby terminal protocol implementation has smooth abstractions from methods performing the bare VT control calls up to semantic methods with better naming, to flexible and extensible text field abstractions. All the concerns are separated nicely and Ruby lets me scope everything just right, so I can call a debugger anywhere as the necessary logic is scoped module-wide.
I simply cannot imagine having any kind of fun doing this in a static compiled language. And I'll be able to build on top of this to make things that aren't editors.
Why Rust? Because I like its power and with recent developments such as subsecond the compile times are absolutely negligible.
Haha!
[1]: https://upload.wikimedia.org/wikipedia/commons/d/d4/Human_fa...