A declarative desktop UI framework for Rust built on GTK and GTK-rs
github.com
github.com
I’m building a video editor [1] (actually rebuilding an app that was originally in Swift) and I’ve been happy to see that the performance is great. I think it feels faster than some of the Qt-based editors I’ve tried. I haven’t noticed JS being the bottleneck - way more often it’s been that I’m doing something sub-optimal on the Rust side.
Tauri still feels early in some aspects, but it’s moving quickly and they’re buttoning things up. I think it’s already a strong contender in the space currently (mostly) owned by Electron.
The simple use-cases like "Window > Box > Label" are easy to get going. The more complex widgets like Stack/Grid/TreeView ... aren't.
This project seems to have the same issue: https://github.com/bodil/vgtk/issues/40
This is made more difficult now GTK4 has removed the Container base class, so there's no longer a unified interface for adding children (although it had caveats in the first place).
I totally get the GTK view that (presumably) specific widgets are more intuitive with specific add/remove APIs (like the grid - one doesn't really "appendChild" to a grid).
It just feels like: if there was a consistent container API comparable to the web's appendChild approach, a vdom/declarative approach would require only a very light wrapper. Without it, I keep coming back to the idea of implementing wrapper widgets that expose that consistent API instead. And that's just not something I want to maintain - effectively duplicating each GTK widget for the purpose of making it fit into a tree model.
It's also a problem of trying to wrap richer functionality (pack_start and pack_end) into a simpler set (append only) of course.
So I don't know exactly what my point is :) Perhaps cautioning the reader that the simplicity of the approach comes with a catch.
Let's not throw out all the work that went into Gtk/Qt but instead embrace it. Bindings/wrappers that are idiomatic in the target language. Maybe including a small state or declarative layer and lean on the framework for rendering, input events, windowing, accessibility, etc.
Another example of this approach is TornadoFX which is a declarative Kotlin DSL on top of JavaFX.
Additionally, there's an added benefit if you're building non-(L)GPL software with it: you can just use the compiler defaults (statically link Relm4, dynamically link Gtk) and stay compliant.
Here’s a good discussion on it: https://internals.rust-lang.org/t/rationale-of-apache-dual-l...
It's horrible in JS because of the boilerplate
It's ok in rust, at least you have types
It feels like a lot of code needs to be written, but in my experience that's because it necessitates thinking about the edge cases in a way that you can try to ignore with more imperative UI or data flow.
I've used the Elm paradigm in Elm and in Swift on iOS. Would definitely use it again for any data-driven complex UIs like apps or big web frontends.
Reading "Elm architecture" (https://guide.elm-lang.org/architecture/) it looks like classic MVC - they just call it Model / View / Update instead of Model / View / Controller.
If not, the rest of my comment is invalid.
> I personally can't stand the amount of boilerplate and "indirect thinking" that it requires.
Of course, just because you use a classic paradigm it doesn't mean the implementation thereof is elegant. And that might be because according to the Elm docs programmers "stumbled" upon it (reinvent) instead of designing for it: "Rather than someone inventing it, early Elm programmers kept discovering the same basic patterns in their code."
(Which is too bad, the ideas behind the project seem sound.)
Do Rust projects have a tenancy of becoming abandoned maybe due to the complexity of the language since it's hard to contribute? I've seen enough cases on this that prompted me to ask this.
1. Rust projects become abandoned (observed fact)
2. Language complexity (?)
3. Hard to contribute (?)
I guess that’s why you were kind of defensive when you brought it up.
Rewrite-in-Rust is a thing. Not only for applications but also for foundational libraries (crypto, http, async, etc). The ecosystem is still young with lots of gaps and many devs are experimenting with new approaches to fill those gaps. More new projects -> more abandoned projects.
Other languages had similar teething problems, just ask anyone with applications in Zope, WebPy, Pylons, Merb, JS frameworks not named React, EJB, MFC, etc.
Python is an outlier though; it was mostly ignored until very suddenly it took off starting around the time Jupyter released.
Most (including I) think it took off due to how easy and accessible it was back then, syntax-wise. You could pick it up and be slightly productive in a day, be extremely productive in a week and essentially master it in a month.
Go is following a similar trajectory: productive contributor in a week, master in a month.
Rust is in the opposite direction: too many people simply give up on it, those that persevere report months before any reasonable productivity.
Reddit and Eve are interesting in being largely stuck with the now-dead platforms they built on too, in the form of web.py and Stackless Python. YouTube I presume the original Python application is gone in favour of a bunch of Go and Java microservices by now.
It's interesting as someone who was in the Python for web development camp as Python for scientific computing took off as the two camps were both oblivious to the existence of the other in many cases.
Wasn't PHP the king of dynamic laguages for Web?
I don't think Rails/Ruby was ever used more than PHP.
IIRC, PHP at its lowest popularity ever is still higher than Rails/Ruby at it's highest popularity ever.
The lowest I can recall PHP being at is +-6% (recently). The highest that Rails/Ruby ever got to was <3% (2004/2005/2006).
Major scientific libraries:
- SciPy: "Around 2001"
- ipython: 2001
- Matplotlib: 2003
- NumPy: 2006
- Pandas: 2008
Major web libraries:
- Zope: 1999
- Twisted Web: 2002
- WSGI: 2003
- Django: 2005
- Pylons: 2005
Applications mentioned:
- Eve Online: 2003
- YouTube: 2005
- Reddit: 2005
I don't think this justifies the claim that the web python community was around at the same time as the scientific community while the two were relatively unaware of each of other as "revisionist". It just makes it look like you were in the camp that was aware of the scientific stack and not the web stack.
I didn’t dispute this, please reread what I said again.
> It just makes it look like you were in the camp that was aware of the scientific stack and not the web stack.
No, actually I’m a web stack Python guy mainly, I just actually know my history.
But like, if you're trying to do something you'd otherwise do in C++? Audio/video processing, or something along those lines? Yeah, it's fine. The common libraries you choose today are likely to be maintained going into the future.
Other languages don't have as fun a type system, so I feel bogged down and lose motivation before I even start writing code.
I don't know how many others this applies to, but I have a lot of abandoned Rust projects because if it wasn't in Rust, I never would have even started writing them down before abandoning them.
https://twitter.com/bodil/status/1520404060138094592
The author of this crate enjoys advanced type systems, and can't wait for Rust to add what you'd call "more complexity" in the form of higher-kinded types, generic associated types, and specialization (some of these features are available in an unfinished/experimental form in the nightly compiler, but may not become part of the language anytime soon, if ever).
The api is just better and gives you more for the bang