Servo: the ultimate UI toolkit for Rust?

Hello everyone, this is my first post here :slight_smile:

I'm still reading the book so I have lots left to learn :smiley: However even now I understand how Rust is a truly innovative and game-changing language. From some researches I've made it seems that there isn't yet an official or at least good enough UI toolkit to rival something like QT. This unfortunately prevents using Rust for many projects.

Then this idea came to mind: why not embed (some components of) Servo in the standard library and build a toolkit around it? This would come with some serious advantages: the drawing code of a toolkit is IMHO the most tedious and time-consuming to write, and drawing a beautiful UI is quite hard (I often use Java Swing, which is very powerful but somewhat ugly to see).

Relying on Servo would hugely alleviate this aspect: layouts and components would (ideally) be only custom HTML elements (to write once and put in the standard library) and CSS (to update sporadically when a new version of a particular OS/toolkit to mimic comes out). This approach would also enable developers to perform powerful styling for free.

The UI toolkit should "only" implement a DOM-like Rust API and a main loop. Sure there are things I did not consider, but nonetheless I'm sure this approach would be far simpler, much more powerful and less redundant than drawing widgets from scratch or try wrapping natives.

What do you think about it?

1 Like

I think variants of that path are being explored by Azul (uses Servo tech, but not fully web-based) and Neutrino (web-based but not Servo-based).

However, note that GUI in Rust is very much WIP and immature, and therefore unlikely to land in std anytime soon (as std's stability constraints are not compatible with the sort of throwaway design experimentation that this realm needs right now).

1 Like

Hi HadrienG, sorry for the late response.

Amazing, I didn't know about these framework, but it seemed so logical to me that it was strange that no one tried it yet. Thanks I'll give them a try :slightly_smiling_face:

This has been discussed several times. Basically what Electron is, just with Servo. I still don't think a mainly native, AOT-compiled, systems-oriented language should have it's primary GUI library be a web thingy. Those attempts (along with technologies primarily intended for mobile app development like React Native, NativeScript, or even older stuff like PhoneGap) somehow always end up being bloated, slow, and not working truly uniformly across platforms.

Embedding a browser engine also has enormous(ly negative) security implications. Not to mention the need for learning at least 2 more languages (HTML and CSS) properly, just for the sake of building a GUI, which for one I wouldn't be willing to do.

I think Rust has the realistic opportunity of doing something much better. Let's not repeat past mistakes.

1 Like

In fact you always learning something and I would much rather learn HTML and CSS than some custom way to build gui widgets. With HTML/CSS there is a chance that a dev already knows some of it + it's easier to give a project to some frontend dev for prettyfying + there is a option to play with design in a browser and then just moving CSS to be embedded in rust program.
I'm writing my first reasonable project in rust and I desperately needed a GUI lib. There is no good option at the moment and I my current approach (#6) is client / server design: rust -> actix -> vue -> js. That's actually easiest way to find someone who knows all used tech and quickest way to get the job done.