3 ms·
Doing GUIs with Rust is difficult. Gtk-rs lucked out because Gtk has introspection that maps out its C object API. Qt is not so good. Something simple like Win3
by BearOso 6y ago
Doing GUIs with Rust is difficult. Gtk-rs lucked out because Gtk has introspection that maps out its C object API. Qt is not so good. Something simple like Win32? Not so good.
Maybe I want to write a game. Gfx-rs is deprecated. Its replacement? It’s in a half ready beta state, and most of its developers are now focusing on a compatibility wrapper for MacOS, so progress is stalled.
The ecosystem just isn’t there. System libraries have an interface that is extremely suited for C. Interfaces have to be uniquely adapted for rust or be marked completely unsafe. Dynamic linking is convoluted, so Rust encourages statically linking everything. It’s not easy, and the situation needs to improve or Rust will be relegated to just another text processing language. C library symbols need to be accessible as a first-class part of the language.
- jeroenhd 6y agoI agree the ecosystem isn't there yet, but given some time that will correct itself. Perhaps Rust will not be able to interface with Win32 because of its reliance on pointers, but there's the possibility of leveraging alternative programming interfaces such as the abstractions in the .NET runtime. I believe that if Python and Java can have cross-platform GUI libraries, so can Rust. I don't know what the result would look like but the tooling has already massively improved since I first looked into the language. I'm too annoyed at GTK for their obsession with client-side decorations messing up the native look on Windows and other platforms to use it for my own projects, but the Qt integration didn't look all that bad in my opinion. Rust-qt is clunky because the Qt API requires unsafe code, but with some work the unsafe parts can be abstracted away from the main program logic. It's suboptimal but it does allow you to do data and network traffic parsing and handling in a safe manner, which would already be a huge win for application security in my opinion.
- steveklabnik 6y ago(Rust can absolutely interface with Win32, and Microsoft themselves have implemented bindings to WinRT.)
- jeroenhd 6y agoInteresting. In my experience, a lot of Win32 messaging required converting pointers to structs and reading values from that. I don't see how that works with Rust? I suppose you can add a load of unsafe code but that would make the whole thing a lot more complex as you now need to deal with pointer ownership and (de)allocation.
- steveklabnik 6y agoYes, because it is FFI you have to use unsafe to do so. Almost 20 million all time downloads: https://crates.io/crates/winapi https://crates.io/crates/winapi And the other bindings I was talking about https://github.com/microsoft/winrt-rs https://github.com/microsoft/winrt-rs