What is the execution efficiency of desktop applications developed in Rust?

What is the execution efficiency of desktop applications developed in Rust?

We know that the Rust Tauri framework is a GUI framework developed in Rust. Is the execution efficiency much lower than that of desktop applications written in C/C++?

Is it recommended to use Rust to develop desktop applications like Photoshop and Premierer?

Rust compiles to native machine code that your computer runs directly. There is no run-time over head, no garbage collector, etc. All in all much like C, C++, Pascal, Ada, etc. As it happens the Rust compiler uses the LLVM compiler backend for optimisation and code generation. The same LLVM as used by clang. So the resultant code is much the same as that for C and C++.

In all my little experiments with Rust I have found that it easily matches the speed of C. Sometimes a bit less, sometimes a bit more.

2 Likes

Desktop applications these days have various sources of inefficiencies

  • The UI technology. If you choose to embed a browser engine and run some heavyweight SPA JS framework in that engine in the end you're just running a sluggish single-threaded web app in a custom browser. Whether you use NodeJS or Rust to start up the embedded browser engine will hardly make a difference.
    So you'll have to carefully pick UI libraries that cover your usecases but are closer to native or achieve efficiency some other way (e.g. by making use of accelerated graphics APIs).
    Rust libraries can be fast here, but not all of them will be.
    And UIs are hard, many libraries are still new and not necessarily featureful, so some tradeoffs between features, perf and portability may be necessary here.
  • Execution of the core logic. If you're doing number crunching, pixel swizzling or need fine control over IO then doing those in lua or python would be bad for performance.
    Rust definitely does better on those fronts, by being a language that compiles to native, optimized code, supports safe multi-threaded code and has memory-efficient data structures etc. etc.
  • Bad coding practices. O(n²) loops, N+1 queries, gigabyte-size XML documents abused as databases, ...
    Rust itself can't save you from bad coding.
    On the one side many APIs are designed to make doing the right things easy. And the community does care about the performance reputation. And there are lots of high-performance libs out there.
    But on the other hand only hiring junior devs and management pushing featuritis over quality will eventually end up in a slow application by a thousand cuts.

TL;DR: Rust provides a very high performance ceiling, so you can use it to write efficient desktop software. But there are many things you can do to fall well short of it, so the choice of Rust alone won't guarantee success.

6 Likes

I have a very serious desktop application here, written in Rust. The Zen editor https://zed.dev/. Give that a try to see what performance one can get from Rust for the desktop.

1 Like

Note that you can also mix languages. For example, use a high level language to write the UI but then call into Rust to do any work.

Yes

1 Like

Not just from Rust, but also for Rust. I switched to zed a couple of weeks ago and like how well it works together with Rust. Syntax-highlighting, errors, hovers, ... And I did quit using sublime.

Rust is among the fastest languages (at least in microbenchmarks…).

GUI frameworks for Rust are still mostly immature, but they can be fast too. For example rerun uses egui for big complex visualizations.

Tauri will be more efficient than Electron, but mainly due to using system's own web view, instead of bundling all of Chrome.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.