DEV Community

Cover image for Rust GUI: Introduction, a.k.a. the state of Rust GUI libraries (As of January 2021)

Rust GUI: Introduction, a.k.a. the state of Rust GUI libraries (As of January 2021)

Davide Del Papa on January 18, 2021

[Photo by Kelly Sikkema on Unsplash, modified (cropped)] This article follows up on a discussion. Please share your experience there, I'd gladly h...
Collapse
 
nothingismagick profile image
Daniel Thompson-Yvetot

Just a headsup - Tauri does NOT ship with a nodejs backend. You may sideload a nodejs based binary, but in its normal (and recommended shape), it is a 100% rust backend and HTML/CSS/JS shipped to the frontend.

Collapse
 
nothingismagick profile image
Daniel Thompson-Yvetot

I think maybe the clarification needed is that you MAY use a nodejs based harness for building your distributables (like vue, svelte, etc.) but that is not required. At the moment we are still using nodejs to run the HMR server and rig cargo for building the final app, but we are planning on releasing a pure rust version of the CLI and are looking into actually making a pure binary CLI / Bundler... At any rate - thanks for the great article!

Collapse
 
davidedelpapa profile image
Davide Del Papa

Hi! First of all, thanks a lot for the good job on Tauri!
I edited the article reflecting your comment. Really thanks again to you and all the people behind this software. We need more of this in the Rust community: projects well thought of, and that run out of the box.
Keep up with the good job!

Thread Thread
 
nothingismagick profile image
Daniel Thompson-Yvetot

Thankyou!

Collapse
 
chiroro_jr profile image
Dennis

Is there a tutorial that shows how to sideload a nodejs backend? I want to build a desktop application that uses a biometric fingerprint sensor. The company does not have an sdk for rust but they have one for JS. The other things is I'm not too good at Rust. I can do well with JS though.

Collapse
 
marcin_codes profile image
Marcin • Edited

Hi,
I made Taurine for the same reason. I can be more productive in nodejs than in rust. Here is a link to how to make a bundle of your code and nodejs into a single executable binary and run it as a sidecar: github.com/marcincodes/taurine

Also, I wrote a post with more explanation and rationale behind it: marcin.page/posts/tauri-+-nodejs:-...

Collapse
 
walkero profile image
George Sokianos

@davidedelpapa Thank you for the awesome research. I would like to ask you which of the above GUI libraries produce the smallest binary, because this is also a necessary information to know. For example the Iced example of yours produced a 213MB binary on my system, and the Druid one is 115.8MB.

It would be interesting to have this information as well. Thank you so much for this work.

Collapse
 
davidedelpapa profile image
Davide Del Papa

I think the sizes you are getting are due also to the fact that if you just 'cargo build', you get a debuggable executable. If you 'cargo build --release' you should get smaller bins.

Anyway, yes final size is a valuable metric. I'm planning a retake on this, also because some crates have evolved quite a bit since I tested them, and some are finally usable (yeah). In tht case I will try to spend two words about binary size

Collapse
 
lexiebkm profile image
Alexander B.K.

Wow... hundreds of Mb. This may discourage me to use Rust for desktop GUI.
I am considering to relearn C++ and use Qt.
Java is the other option with Swing already provided in the JDK.
Another very good option is C#. But it requires .Net framework, because the last time I read, .Net Core didn't provide support for Win Forms, WCF, WPF. Besides, C# + .Net are massive technologies that will take longer time to learn and get proficient.
That being said, I still want to continue learning Rust for other purpose, probably for web backend.

Collapse
 
walkero profile image
George Sokianos

I think you missed Davide's comment below. Actually the binary became quite small when I used cargo build --release to build it. So, my comment above is not accurate any more.

Thread Thread
 
lexiebkm profile image
Alexander B.K. • Edited

You are right. Without including debugging feature, by adding --release option, the size would decrease much smaller.
But, when I build and compared two simple button apps, I got the result :

  • Rust app is 17Mb
  • C++ app is only 132Kb. I also tried a small GUI app using C++ that had a feature of simple datagrid (table) where the cells are editable and found the file size was about 1Mb which is acceptable. This type of desktop GUI app is one that I had developed in the past using Visual Basic 6. One thing that I also found when compiling even a small Rust app like that, the compile time was very long on my computer. It could take 1 hour or more.
Collapse
 
noracodes profile image
Leonora Tindall • Edited

Hi! I am the developer of IUI (libui wrapper). You mentioned that development was halted - this is because most of the improvements I want for the next version are not possible until libui, the underlying C library that interfaces with OS components, fixes some serious design issues. I am confident that this will happen and as soon as it does I will update the IUI wrapper code.

Collapse
 
davidedelpapa profile image
Davide Del Papa

Hi! First of all, thanks a lot for the good job on this library! It is an enrichment for the whole Rust community.
I edited the article reflecting your comment.

Collapse
 
tieje profile image
tieje

Absurdly well done.

Collapse
 
gberthiaume profile image
G. Berthiaume

Wonderful article.
I completely agree with your conclusion: in this world full of electron app, having a solid rust GUI ecosystem would be wonderful.

Immediate mode GUIs belong to the gaming world, not to the Desktop Applications world.

Could you elaborate on this? I'm part of neither of those communities, but I like to better understand your statement.

Collapse
 
crax97 profile image
Crax

Immediate GUIs are repainted at each frame, meaning it's a waste of resources for desktop applications, as desktop GUIs don't update very often

Collapse
 
cthutu profile image
Matt Davies

That's not true. You can decide when to update the frame (e.g. an input event coming in). What is true is that usually the whole UI is repainted when a change does happen.

The author is absolutely wrong about ImGUI belonging to the gaming world. I have written a complete Unity-style editor using ImGUI and it was the best decision I ever made. I had to solve some issues such as layout and drag'n'drop with some custom code, but when this had been done, writing UIs and maintaining them became MUCH easier than more traditional widget-based approaches. You are liberated when you don't have to worry about lifetimes in a very dynamic environment.

Also, the author doesn't understand really what ImGUI is. It's sole purpose is to return vertex buffers and commands for the host to render. As a result, there is a lot of boilerplate to set that up. But ImGUI has many examples that implement a host using DirectX, OpenGL and others. You have to write it once and then you're done.

Thread Thread
 
gberthiaume profile image
G. Berthiaume

Do you have further reading to suggest about this ?

Thread Thread
 
cthutu profile image
Matt Davies

What specifically? Everything I've written is in the "Dear ImGUI" documentation, which you will mostly find in its source code. The part about writing an editor using Dear ImGUI is something I figured out myself at my job. I think Dear ImGUI has better support for layouts then it did when I wrote my editor, which was around 5 years ago. But you can see images of ImGUI efforts: twitter.com/proceduralguy/status/9...

Thread Thread
 
0lru profile image
0lru

That's not true. You can decide when to update the frame

Yes, you can. . But it isn't trivial. Here is my unfinished solution: github.com/0lru/p3ui (I think it'd require something like virtual dom in React to be lock-free and smooth). The thing I like about "ImGui" is its functional scope. Most of the provided frameworks here do not include performant plotting libraries like ImPlot. Although even ImPlot is not as performant as it could be. When looking into chrome and other GUI-related frameworks like React with its virtual dom, you begin to understand the problems and their solutions. In the end, it seems it's not only a rust-related problem. I don't know any framework that would make me fully satisfied, in any language, yet.

Collapse
 
mashgraz profile image
mash-graz

that's a really good, up to date and complete comparison of available rust GUI solutions!

only egui should be also added to the list

Collapse
 
davidedelpapa profile image
Davide Del Papa

I might add a section or make another article about this and other immediate mode GUIs... My only concern was, and still is, that these are more useful for gaming than for desktop apps. To say the truth i didn't try egui yet.. let me try and I'll tell you also what I think...

Collapse
 
mashgraz profile image
mash-graz

yes -- i perfectly understand this judgment!

i also wouldn't recommend it for any serious huge project, but it's an extremely simple and lightweight solution -- just like the FLTK port --, which even works well in WASM and on the android platform, although not really as perfect as more native GUI solutions. but if you want to stress the opposite side of the spectra, you should perhaps also mention flutter and its simple C-FFI-binding capabilites, which are often used for realizing more advanced GUIs resp. frontends for rust applications on mobile devices.

nevertheless, i really like your list and presentation of the different available solutions.

Thread Thread
 
davidedelpapa profile image
Davide Del Papa

Then maybe I would surely need to make a take two, with egui and other immi mode GUIs, Flutter, and some others I discovered very recently, such as neutrino (too bad some are unmaintained tho 😥). If you know more that could go on this list, please let me know! I left open for discussion the first post, so maybe we can add GUIs to the list. The more the options the better!

Collapse
 
popbee profile image
Bernard Poulin

What a MASSIVE article! Kudos to your work. Kinda reminds me that Rust aims at correctness over simplicity. A world where GUIs might not be the primary focus. I hope you article helps getting more GUI tractions!

Collapse
 
girkovarpa profile image
GirkovArpa • Edited

I do not believe the following quote is true:

"The other caveat is that the executable may send diagnostic data to one of Terra Informatica 's servers. They are very clear that it may, and maybe (for what I read) it's just diagnostic (it should not infringe the EU protection laws in matters of personal data...). Anyway, the important thing is that you are aware."

Where did you read this?

Collapse
 
davidedelpapa profile image
Davide Del Papa

Here's the answer from the author (I believe)
The key distinction he does is between may send, and does send, which I think is fairly represented in the article.
Bear in mind, the author is campaigning to raise money to open source the software, so this actual or potential behavior might soon be removed.

Collapse
 
girkovarpa profile image
GirkovArpa

Okay, I was quite surprised to read this because I've been experimenting with Sciter for awhile now and I have a firewall setup to require my permission anytime any application tries to use the internet.

And Sciter has never attempted to do so, apart from instances where I've deliberately used its URL loading functionality.

Thread Thread
 
davidedelpapa profile image
Davide Del Papa

In fact, as he was saying, maybe it was a mechanism in place that was never used. In any case it's nice that they've been forefront in this, stating the code was there in place.

Collapse
 
lexiebkm profile image
Alexander B.K.

Do you think it is appropriate to use Rust for desktop GUI app ?
My concern is file size and compile time, esp in comparison to C/C++.
I build two simple button apps like shown in this article; one used Rust with GTK, the other used C++ with GTK (gtkmm). I got the following result :

  • Rust app was 17Mb using --release option, with compile time about 1 hour. I didn't measure the exact time, because it was very long. Because of this very long compile time, I didn't continue on trying other features provided by GTK-Rust such as ListView, Menu, etc.
  • C++ app was only 132Kb, with compile time only about 1 minute or so. So I could continue on trying other interesting and useful features such as ListView, Menu, etc.
Collapse
 
lonami profile image
Lonami

sixtyfps.io/ is being mentioned in other sites (Reddit, lobsters), so I thought I'd leave it here.

Collapse
 
migepatschen profile image
migepatschen

I did a small test project with slint-ui.com/ (they renamed themselves in February 2022) and was pleased how easy it was to alter the look and feel to match the design guidelines I set as my target.

Anyone willing to share their experiences with it?

Collapse
 
lexiebkm profile image
Alexander B.K.

I am getting started to use GTK for C/C++.
I am glad seeing that most of successful tools you described here are based on GTK, including Druid. You even gave a good description of GTK here which I agree : starting with GTK first, including using Glade, and then try the others.
That is the path I will take, so that I can use same tools for different languages.

Collapse
 
hb profile image
Henry Boisdequin

This is gold, incredible content! Thanks for sharing!

Collapse
 
jrop profile image
Jonathan Apodaca

This was a very thorough and enjoyable read. Thank you for putting it together!

Collapse
 
detly profile image
Jason Heeris

Just FYI — what you've labelled "LittleVGL" hasn't been called that for a while, it's usually known simply as "LVGL" which is taken to stand for "light and versatile graphics library". You don't need an embedded system to run LVGL, it has an SDL "simulator" or runs on web. Indeed I run it on my dev PC to test all the time. (I use the C API directly, so I can't vouch for the Rust bindings.)

Collapse
 
gthome profile image
Gabriel Thomé

dude you're a hero for taking so much time experimenting with crappy ass libs so we don't have to

Collapse
 
mankinskin profile image
Linus Behrbohm

You might want to add/look into seed-rs, a web frontend framework for webassembly. It interfaces with the browser through web_sys and provides an elm inspired web UI framework.

Collapse
 
davidedelpapa profile image
Davide Del Papa

I mentioned Seed also in talking about Iced. However, Seed, Yew and their WASM friends are for the Web interfaces, not the Desktop GUIs. Indeed I'm in love with the WASM stack, but I had to draw a line on the technologies. I did a series of articles on Yew, and Seed is on my shortlist of WASM technologies to try.

Collapse
 
leandroats profile image
Leandro Torres

Very useful article. Thanks for sharing your knowledge.

Collapse
 
devdufutur profile image
Rudy Nappée

If you look at mature and full featured lib to write Win32 GUI, try Native Windows GUI. It wraps Win32 C API in a really clean way and use rust derives to allow declarative patterns

Collapse
 
cryptoquick profile image
Distributed Hunter Trujillo

I've actually been building a full-fledged app in Iced and found it to be very capable and performant. Check it out!
github.com/FuzzrNet/Fuzzr

Collapse
 
axim0s profile image
AXON • Edited

I found something small:
dev-to-uploads.s3.amazonaws.com/i/...

Nice article though.

Collapse
 
diegodorado profile image
Diego Dorado

Thank you for this post! It was really useful!

Collapse
 
dasaki profile image
David Sanz Kirbis

Thanks for the article. In case someone here is interested in creative coding with rust there is also this project:
github.com/nannou-org/nannou

Collapse
 
antonov_mike profile image
Antonov Mike

Thank you for bringing all the libraries together! Very helpful post!

Collapse
 
danielswolf profile image
Daniel Wolf

Thank you for the great article! You mentioned that you're planning to update it to cover the latest versions of those GUI frameworks. That would be great, given the pace of development! Any news yet?