14 ms·
Are we GUI Yet? The state of building user interfaces in Rust
- Communitivity 5y agoEdit: Ok, I was wrong. I thought Tauri was also being used as a platform for Rust development, not just Javascipt. Also, it's not buried..just not highlighted. First comment of the day did not get off to a good start. What surprised me was that Tauri was buried and not mentioned as a viable Electron replacement. I think we will eventually get to the point where native OS UI is a Web UI, with the OS UI running on a special virtual interface for security. I have seen Web-based UIs that are every bit as nuanced, complex, and well-designed as native UIs. Two bits are not quite there yet though. First, performance of Web UI has improved amazingly, but until we do have native support integrated into the OS it's going to be a step behind. Second, as already mentioned, accessibility must be accounted for.
- the_duke 5y agoTauri is written in Rust, but it's a Electron alternative, with user code written in Javascript. It deserves a curtious mention, but it's not really relevant to a Rust UI development. (Sure, you can write UIs via WASM now, but that's equally true for Electron)
- jagged-chisel 5y agoBuried? It's right there on the page, alphabetized like everything else.
- anthk 5y ago>performance of Web UI has improved amazingly You didn't live with the computers' UI from the 90's and 00's, right? It looks so.
- kaba0 5y agoIt is ridiculously fast for what it does. There’s another question that it does plenty of unnecessary computations for the end-goal and is probably not a good basis for.. well anything to be honest. It is not good at layouting, nor interactions.
- pjmlp 5y agoMicrosoft's ongoing efforts for WinUI seem to be missing. https://github.com/microsoft/microsoft-ui-xaml/issues/2488 https://github.com/microsoft/microsoft-ui-xaml/issues/2488 As mentioned on the thread, the current samples are at https://github.com/microsoft/windows-rs https://github.com/microsoft/windows-rs
- ginko 5y agoThat doesn't seem very useful if it's Windows only.
- mumblemumble 5y agoOne of the tags you can select is WinUI. Another is MacOS. So they clearly thought platform-specific UI might be usful to someone. It may not scratch your itch, but that doesn't mean it's useless. For my part, I'd argue that, if you care about inclusiveness, you should probably favor either Electron or some other option that builds on the Web stack, or writing a separate native front-end for every platform. The problem with all the cross-platform toolkits is that they have accessibility problems.
- pjmlp 5y agoTargeting 90% of the desktop consumers and non-iPad Tablet owners (Android tablets are being overshadowed by 2-1) seems pretty useful business opportunity to me.
- bruce343434 5y ago> 90% more like 76%: https://www.statista.com/statistics/218089/global-market-share-of-windows-7/ https://www.statista.com/statistics/218089/global-market-sha... Can't be bothered to verify the tablet claim but that's probably wrong as well.
- kitd 5y ago76% versus 16% for the next highest. Is it really worth the argument? ed: https://gs.statcounter.com/os-market-share/desktop/worldwide/ https://gs.statcounter.com/os-market-share/desktop/worldwide...
- zamalek 5y agoThere's a lot of custom rendered stuff there. The problem with that is, without a lot of work, custom GUIs are completely opaque to screen readers and other accessibility tools.
- dvfjsdhgfv 5y agoPlus they always feel a bit off.
- cunthorpe 5y agoThey don't feel off, they are off. But with the popularization of apps, webapps and Electron everyone is accustomed to custom UIs for every app. Does the Spotify app feel Mac-like? Barely. Does it need to be? Not anymore. I think that as long as we don't see badly-drawn UIs and "ugly styles" (like Java apps’ gradient buttons) we're good nowadays (given that someone actually designed the UI)
- machello13 5y ago> Does it need to be? Not anymore. I disagree. The fact that most users don't explicitly care is irrelevant — platform conventions are important. They teach a user how to use a new app without having to poke around. Users can drag and drop from one app to another and it just works. I certainly see the argument that for many companies, it's simply too expensive to write native apps for every platform. But I don't think we need to pretend that non-native apps aren't worse — they're just economical and generally, even at their best, just _okay_.
- cunthorpe 5y agoGenerally I prefer an app that exists to an app that doesn't exist. Companies that can afford multiple teams are still going the multi-platform way and those who can't, still do it. At the end of the day, you can choose the best app available. I too would like every app to be a 2MB Swift app, but those are rare for a reason.
- rvz 5y agoSo still not ready yet and is still not mature or production ready either. Until there is a mature library that is able to compete with Electron or Qt then I'm afraid that Rust is not a sensible choice for serious cross-platform GUI development at this time. Like I said before [0] With these libraries, All you get is a mixture of unmaintained or unstable bindings that may break when the GUI library that it is using changes its API. No thanks and no deal. To Downvoters: So you are telling me that you can confidently recommend to any engineering shop to develop a very complex GUI app with either of these unstable libraries faster in Rust than one who uses JS/TS with Electron? Even though I hate Electron, I can see why it is always chosen. Rust for GUI development? I don't think so, especially if you have a short time to release something complex and used by thousands into production. [0] https://news.ycombinator.com/item?id=24537300 https://news.ycombinator.com/item?id=24537300
- wiz21c 5y agoyep. Harsh judgement but true judgement. Now there's rust-qt but I dunno how good it is.
- Popegaf 5y agoIt uses a lot of unsafe rust code. Here an example https://github.com/rust-qt/examples/blob/master/widgets/basic_form/src/main.rs https://github.com/rust-qt/examples/blob/master/widgets/basi... I'm not sure what's the advantage of using unsafe code everywhere in Rust compared to just using C/C++. The syntax?
- cdirkx 5y agoBeing part of a bigger Rust project? The GUI is just one component after all.
- nonbirithm 5y agoEven for unsafe code Rust was designed to be more ergonomic than C (like pointer arithmetic operations). That said a safe wrapper would be preferred to unsafe everywhere.
- wdb 5y agoThe cross platform frameworks are most of the time a disappoint for at least one part of your users as it does a bad job at mimicking typical OS interactions.
- kitsunesoba 5y agoOr in some cases, they don’t even try to mimic native widgets. By far the most common example I come across is text fields, which in most cross platform UI toolkits aren’t even half as functional as their Cocoa/AppKit counterparts. It’s incredibly frustrating for things like text navigation key shortcuts to work in the majority of your day to day apps, only to have the habits and muscle memory run into a brick wall when you need to use some cross platform app. Lowest common denominator UI is just… ugh.
- grumblenum 5y agoHas this actually changed since 2017?
- grayrest 5y agoThere are a lot more options but nothing that's clearly winning. The first projects I'd check for building a GUI today are Microsoft exposing the Windows UI toolkit and the Rust+Flutter integration. I know that the GTK crowd were engaged with the Rust core team years ago but I don't know if anything came from that. I'm still on the DOM-as-the-main-platform train (since 2001, I believe in the Mozilla vision) so I haven't been tracking the details that carefully.
- brainless 5y agoI just opened this today, what a nice coincidence to see it here. I want to create a cross-platform app to show some information on a Git repository. I do not have many UI widgets, it is just a visualization in a way. I also want to continue learning Rust. So I want to create this in Rust, but I am not sure if that means my project will take many many months. I thought of desktop web-app too, using Tauri (1), if this effort is too much. 1. https://github.com/tauri-apps/tauri https://github.com/tauri-apps/tauri
- cloudhead 5y agoFor Rx[0] I built a custom GUI using opengl and Luminance[1]. I'm very happy with the results and would do it again if I had the chance. I'm a Linux user, and there is no acceptable GUI framework to may taste on Linux, so this was the only option that: * Has minimal dependencies * Looks and works the same on all platforms * Performs well and gives me the control I need [0]: https://rx.cloudhead.io/ https://rx.cloudhead.io/ [1]: https://github.com/phaazon/luminance-rs https://github.com/phaazon/luminance-rs
- jagged-chisel 5y agothe luminance-examples links under 'Other crates' in your README.md give 404
- themaxdavitt 5y agoNot affiliated with the project but I just created an issue for this: https://github.com/phaazon/luminance-rs/issues/527 https://github.com/phaazon/luminance-rs/issues/527
- imvetri 5y agoGUI is plattform independent. Code is plattform dependent. Have a single language to build UIs, target it to multi plattform.
- thomascgalvin 5y ago> GUI is plattform independent. It really isn't, at least if you want to meet the expectations of the users of each platform you're targeting. It's easy to say "I want a button that says '[Click Me]'." It's less easy to say what the pixels representing that button look like in a platform-agnostic way. Are the corners rounded? What kind of bevel does it have? What sort of visual indication is there when you mouse over? And then there's stuff like layout. Does your form have the buttons ordered `[OK] [Cancel]` or `[Cancel] [OK]`? Because there are platforms that do both, and if you get it wrong, your user will mis-click because of muscle memory. And what do you do when one platform supports a widget natively that you don't? Or when the APIs for a "common" widget diverge wildly? Windows Explorer and MacOS Finder serve the same general purpose, but they aren't identical, either from the user's perspective, or from the API perspective. Java's Swing probably comes closer to "cross platform GUI" than any other package, but it's far, far from perfect, and it solves a lot of these problems by not trying to mimic the underlying OS. Yes, there are themes that get close, but generally, when you're using a Java desktop program, you know you're using a Java desktop program. A lot of very smart people have tried to create "a single language to build UIs," and "target it to multi platform." It isn't as trivial as you make it seem.
- Hackbraten 5y agoFor completeness, there’s also some work-in-progress that aims to provide safe AppKit and UIKit bindings: https://news.ycombinator.com/item?id=23035078 https://news.ycombinator.com/item?id=23035078
- Klonoar 5y agoI actually have a PR open to add this to the site, but I have no clue who maintains the effort. :( Recently pushed out a 0.2.1, and did a mini write up here for anyone interested: https://rymc.io/blog/2021/cacao-rs-macos-ios-rust/ https://rymc.io/blog/2021/cacao-rs-macos-ios-rust/
- Hackbraten 5y agoThank you for your hard work!
- Klonoar 5y agoHeh, thanks. It's more of a passion project - I find that dealing with AppKit is sometimes a lost art, and I'd like to see a cross-platform GUI toolkit in Rust, so I figure this is the best way for me to contribute currently. I maintain that someone (or a team) needs to just take winsafe/cacao/gtk-rs, slap a declarative layer on top, and do the bare minimum set of controls with hooks for users to do custom things.
- jeffreyrogers 5y agoI've done professional GUI programming and there are really only three options that make sense: 1. Write the GUI natively per platform. This is best from a UX perspective but is expensive and you probably need different developers working on different platforms. Other downside is that really advanced functionality is harder to implement and sometimes the performance of native APIs is poor and hard to improve (Apple has this problem frequently). 2. Use a cross-platform framework like Qt (Electron would also go here). This is the most cost-effective solution, but generally does not feel like a native app, which may or may not be a problem. 3. Use a custom GUI framework.[0] Probably the most expensive option and hard to hire developers for, but can be warranted for complex applications like CAD tools, games, etc. The problem with Rust GUI libraries is that they can't really target 1 or 3 so they need to target option 2. But the big players there are Qt and Electron. Qt is popular because it works well, is proven, and has a lot of financial backing. If you don't need something super complicated a decent Qt developer can get it working quickly. Electron is popular because there are tons of web developers and they can be productive quickly. Rust attracts a lot of hobbyists who are talented and have good ideas, but I don't think they have the staying power (or financial ability) to provide something that competes with Qt and Electron. I'm sure it can be done in theory but I don't see it happening in practice anytime soon. [0]: By custom I mean tailored for the type of application you are making, e.g. what a lot of game devs do for their internal tools.
- forrestthewoods 5y agoGood post. However I think you need to differentiate between GUI for internal tools and customer facing products. Dear ImGui is pretty damn stellar for internal tools. Nigh unbeatable along certain axes. Rust has a couple of Dear ImGui inspired libraries. I think for tools and editors Rust is getting close to being perfectly viable. For customer facing GUI I largely agree with your assessment.
- k__ 5y agoTauri seems like the only viable Electron alternative right now, and it's written in Rust.
- 5y ago
- xbar 5y agoIs anyone interested in curating a collection of TUI components in Rust?
- phendrenad2 5y agoProbably the best way to go is to write native GUIs for each OS. That means win32 on Windows, Cocoa on MacOS, and X11 on Linux. win32 and X11 are just C APIs, so those are easy. On Linux you'll need a widget toolkit, such as GTK or Qt or WxWidgets (or many, many more!). MacOS is a bit more complex (the native APIs are exposed as Objective-C APIs), so you'll probably want to wrap your app in an XCode project with all of the GUI built in XCode.
- Klonoar 5y agoEh, re: macOS, I have an effort to make it possible without basically using the foundation crates: https://rymc.io/blog/2021/cacao-rs-macos-ios-rust/ https://rymc.io/blog/2021/cacao-rs-macos-ios-rust/ There’s other projects that wrap the varying frameworks so I don’t think macOS is as bad as it used to be, but I foresee it still being confusing due to missing docs on Apples side…
- nly 5y agoX11 isn't a GUI framework and is already legacy (Wayland)
- YorickPeterse 5y agoI recently looked into this for a while (best I can do is this Twitter thread about it: https://twitter.com/YorickPeterse/status/1412417105329365004 https://twitter.com/YorickPeterse/status/1412417105329365004), as I wanted to see how feasible it would be to write a GUI text editor in Rust. My conclusion is basically "there's nothing viable". _If_ you are OK with basically limiting yourself to Linux/BSD, the GTK bindings are good. However, for a text editor you'll likely need a custom text widget (the GTK ones aren't very good), and that's where things (with basically any GUI toolkit) get tricky. There are a few libraries providing Qt bindings for Rust, but they either focus on QML, are only infrequently maintained (e.g. Ritual), or seem to focus more on exposing Rust to C++; not the other way around. egui looked really interesting, and the immediate mode GUI pattern is really nice to write. Sadly, it's still in the very early stages, and most notably is lacking support for displaying text with different colors/styles. The rest isn't really worth mentioning I think, at least when wanting to write a text editor. They basically all suffer from the same issues, such as: - It not being clear if the library will still exist 2 years from now - Poor support for Unicode (especially Emoji) - No support for assistive technologies - Poor support for flexible text rendering (e.g. multiple colors and styles) - Little to no documentation For a while I thought about just using Electron, or maybe Sciter (that would at least need fewer resources). Technology wise I think HTML makes sense, as it's very flexible (e.g. many GUI toolkits struggle the moment you want to mix text and e.g. images in the same widget) and quite easy to work with. Sadly, Electron is a fat pig and the last thing I want to do is write Javascript in my spare time. Sciter is proprietary, and you can't distribute the binaries yourself (from what I understand). That basically means your project is dead on arrival, at least if you intend to open source it. So for now I shelved my idea. Maybe in a year I'll take another look :)
- GirkovArpa 5y ago> you can't distribute the binaries yourself You can :) You just have to include a copyright notice unless you purchase an exemption.
- amelius 5y ago> My conclusion is basically "there's nothing viable". How is this possible given that the Rust language was created to write the rendering engine of Firefox?
- adamnemecek 5y agoI'm involved with this nanovg Rust clone called femtovg https://github.com/femtovg/femtovg https://github.com/femtovg/femtovg. It's not a GUI framework but I and several other people are using it for building GUI frameworks. Join the discord https://discord.gg/V69VdVu https://discord.gg/V69VdVu. I have recently added wgpu backend that for now lived in my fork https://github.com/adamnemecek/femtovg https://github.com/adamnemecek/femtovg
- deleted 5y ago[deleted]
- deaddabe 5y agoThis website seems like it was not updated since August 2020, from the list of pending pull-requests: https://github.com/areweguiyet/areweguiyet/pulls https://github.com/areweguiyet/areweguiyet/pulls
- ogoffart 5y agoShameless plug to the Rust GUI framework I'm working on: SixtyFPS https://sixtyfps.io https://sixtyfps.io https://github.com/sixtyfpsui/sixtyfps https://github.com/sixtyfpsui/sixtyfps
- celeritascelery 5y agoThis looks really cool! I like the notion of 60fps, meaning “this framework won’t give you a bloated GUI”
- sam0x17 5y agoNo linux tag mumble mumble Note: I know there is a GTK tag, but not everything is GTK
- smoldesu 5y agoI've written a few small, personal tools in GTK-rs[0], and it's GUI-enough for me. I love how quick it is to whip up apps, and how well it supports tools like Glade to build more complex apps. [0] gtk-rs.org/
- celeritascelery 5y agoOne I am excited for is Druid. Is is worked on by some of the same people that the xi editor, and they really understand responsive design and good font rendering. The backend is Piet, which are platform native crates. And then Druid abstracts over those backends. This lets you write GUI code once and then use native API’s and features. https://github.com/linebender/druid https://github.com/linebender/druid https://github.com/linebender/piet https://github.com/linebender/piet
- raphlinus 5y agoThanks! To clarify, the platform abstractions are both in piet, which is 2D drawing, and also in druid-shell, which contains a wide range of other things, including menus, copy-paste, and a good start on IME. I've written lots about Druid. I haven't really chimed in much in this thread, as a lot of the discussion is frankly not that relevant to what we're trying to do. We are currently not focused on making a good out-of-the-box developer experience, which is what most people here seem to be looking for. Rather, we're systematically exploring what it takes to make a good next-generation UI toolkit, and building a knowledge community around that. It turns out there's quite a bit to that, much more than building a toy UI toolkit.
- celeritascelery 5y agoInteresting. What would you say separates a toy toolkit from a “professional” toolkit?
- raphlinus 5y agoFor starters, real text handling. Just doing a full text widget with all the trimmings is quite complex problem. Druid has made good progress on this front but is nowhere near where it should be. I also put IME in this category. As mentioned elsewhere, accessibility. Aside from web technology, Qt is one of the very few cross-platform toolkits that gets this right. I'm happy to see that some other projects, egui in particular, are starting to pay attention. One of the things that Druid doesn't do well right now is integration with 3D and video content. That will depend on the application (it's not needed for font editing), but is definitely needed for a toolkit to be considered general purpose. The implications go deep, mostly because you have to hook pretty deep into the system compositor to do this well. I may do a blog post on these infrastructure topics, depending on interest.
- jms55 5y agoI have a large amount of experience in this space and with Rust in general, and my recommendation is simply that like all cross platform non-web GUIs, it's not ready. * gtk-rs is fairly good, very completely and functional bindings to a functional library. But GTK is also very GNOME/linux centric, is tricky to learn, and not developed as stable or as fast as you might want. Not to knock on the GTK/gtk-rs teams, they're doing amazing work, and imo the best open source GUI library. They've even made great strides in documentation with the new website and API docs recently. Just not quite good enough yet to be recommended for general purpose use. But if you insist on making your GUI in rust, gtk-rs/gtk4-rs optionally with libadwaita-rs is what I'd recommend. * druid and iced are both promising, but too incomplete. * egui and RAUI are nice, but meant for gamedev.