3 ms·
I recently looked into this for a while (best I can do is this Twitter thread about it: https://twitter.com/YorickPeterse/status/1412417105329365004 https://twi
by YorickPeterse 5y ago
I recently looked into this for a while (best I can do is this Twitter thread
about it: https://twitter.com/YorickPeterse/status/1412417105329365004 https://twitter.com/YorickPeterse/status/1412417105329365004), as I
wanted to see how feasible it would be to write a GUI text editor in Rust.
My conclusion is basically "there's nothing viable". _If_ you are OK with
basically limiting yourself to Linux/BSD, the GTK bindings are good. However,
for a text editor you'll likely need a custom text widget (the GTK ones aren't
very good), and that's where things (with basically any GUI toolkit) get tricky.
There are a few libraries providing Qt bindings for Rust, but they either focus
on QML, are only infrequently maintained (e.g. Ritual), or seem to focus more on
exposing Rust to C++; not the other way around.
egui looked really interesting, and the immediate mode GUI pattern is really
nice to write. Sadly, it's still in the very early stages, and most notably is
lacking support for displaying text with different colors/styles.
The rest isn't really worth mentioning I think, at least when wanting to write a
text editor. They basically all suffer from the same issues, such as:
- It not being clear if the library will still exist 2 years from now
- Poor support for Unicode (especially Emoji)
- No support for assistive technologies
- Poor support for flexible text rendering (e.g. multiple colors and styles)
- Little to no documentation
For a while I thought about just using Electron, or maybe Sciter (that would at
least need fewer resources). Technology wise I think HTML makes sense, as it's
very flexible (e.g. many GUI toolkits struggle the moment you want to mix text
and e.g. images in the same widget) and quite easy to work with. Sadly, Electron
is a fat pig and the last thing I want to do is write Javascript in my spare
time. Sciter is proprietary, and you can't distribute the binaries yourself
(from what I understand). That basically means your project is dead on arrival,
at least if you intend to open source it.
So for now I shelved my idea. Maybe in a year I'll take another look :)
- GirkovArpa 5y ago> you can't distribute the binaries yourself You can :) You just have to include a copyright notice unless you purchase an exemption.
- amelius 5y ago> My conclusion is basically "there's nothing viable". How is this possible given that the Rust language was created to write the rendering engine of Firefox?
- YorickPeterse 5y agoI don't think it was created for Firefox, as Rust (in various forms) has been around for over 10 years at this point I think. Setting that aside, Servo and Firefox both implement the UI side of things from scratch I think. I think from a browser perspective that makes sense: you're already writing a rendering engine, so you may as well also use it for your browser UI.
- pseudalopex 5y agoFirefox in various forms has been around for nearly 20 years. Rust was Graydon Hoare's personal project. But I don't think Mozilla funded it for no reason.