My experience building a desktop app with rust + slint-ui

66 points oliveoilcheff 8 comments

Hi everyone!

I wanted to share my experience writing a decent desktop app. I've been using rust + slint-ui, the app is GPL-3 licensed.

First, about the app: Temporis a "pomodoro" timer. I've used a bunch on Mac and Linux. And there are good options on both. But they didn't have the same set of features I was looking for. I ended up writing one that fits my needs. On Mac, TomatoBar, has a ticking sound, that really helped me focus. And on KDE, Francis, has really nice notification messages (to hydrate and stretch) and a progress bar integrated into the task bar, but it stops automatically after 4 sessions and it doesn't have any settings. I thought of contributing to them, but I didn't feel like learning cpp or swift, and I wanted to try slint.

Regarding slint, I have to say, I'm quite happy with it. I know it focuses more on embedded, but it works quite well for desktop. Slint has its own language, very similar to QML (used to write apps for KDE), but feels like a more modern approach. (caveat, I haven't used QML, just saw some issues on "slint discussion" of people asking about a QML approach, and the slint alternative seemed better to me).

It does have some rough edges, like lack of "flex" and a streamlined ecosystem. The browser usually has an API for everything ready for you: notifications, bluetooth, storage, sometimes even interaction with the host if you are using tauri. With slint, you have to hook it with rust, and find out things by yourself.

The biggest pain point, is adapting to something that it's not HTML, there are no classes for example, and some attributes that you'd expect in HTML don't exist in slint. On the internet, is really easy to find HTML components, and with slint you have to build some things yourself, sometimes even a button. It is what it is, but at times, it did make me feel "slow", like "oh dang, I have to write an <a> link myself. For this, I will try the upcoming dioxus version when it's ready.

Slint docs are good enough, I got lost a few times because of the navigation. I would just list the 4 categories together (guides, referece, tutorial and lang integration). But I ended up finding most of the information, and if not, on github.

In the end, the language was really easy to pick up, after I manage to pull the mental effort to learn a new thing. And it turns out, it's quite doable.

For those thinking of using slint, the source code of temporis can be helpful, because the app is not that complex, but still it does shows the interaction between the slint language and rust, plus some multi-platform code, and sending notifications and sounds to the host operating system.

What could I improved in temporis? I feel like I'm doing something wrong with the Rc cloning in the main, I keep repeating the cfg_clone, but I didn't find another way to do it.

What about something unexpected? Well, a side effect of using slint, which I appreciate, is that the default widgets can actually be compiled into the host's styles. Meaning that temporis on mac, looks like a Mac app, and on KDE it looks like a KDE app. It also has support for material and cosmic, but I haven't tried building them.

It currently supports Mac and Linux, I don't have plans to support windows, as I don't have access to any windows machine, but contributions are welcome.

I hope you enjoyed the write up!

Cheers!

Edit:

As pointed out in the comments. I forgot to mention one of the reasons I chose slint: I was trying to build an app with a low footprint on resources. I work within a VM, and linux is usually resource hungry, and with just 16 GB of RAM I wanted something smooth.

The binary on linux is just 21MB, the distributed AppImage is 8 MB and the DMG is just 4.5 MB.

Startup time feels basically instant.

Temporis, on nix with KDE, reports 110 MB of RAM and doesn't report any CPU usage, sometimes spiking to 0.1%