It's not too far from the write-once-run-everywhere philosophy of React native, Electron and similar. One could write their UI state and application logic once while maintaining 3 entry points using the various platform GUI bindings (gtk-rs, cacao, win32?) to represent the UI state.
This has the advantage of a project feeling natural to the platform while still allowing for code reuse between platforms - though you would still need to rewrite widgets/components for each platform independently.
Something that isn't talked about much in the GUI world (outside of mobile development) is how essential multi-threading is to a great application experience. After all, you can't horizontally scale a client device so it's important that an application is able to maximize its use of the available hardware. Rust's borrow checker/ownership model eliminates dangerous multi-threaded code which makes it practical to write highly efficient GUI applications.
Could be good for projects like cross-platform terminal emulators or code editors.
Yes it is. Heavyweight desktop GUI applications like DAWs or CAD or image/video editing are old established technology.
> This has the advantage of a project feeling natural to the platform while still allowing for code reuse between platforms
Having written cross platform native applications: This is a pain in the ass to do well - and there isn’t a particular reason this hasn’t been doable in C/C++ since forever - Rust isn’t some silver bullet. “Abstracting” away the native GUI/UX seems to be a common pitfall for junior devs - how hard can it be they think - then they learn why Qt exists.
> It's not too far from the write-once-run-everywhere philosophy of React native, Electron and similar.
Electron is about as far removed from the philosophy of targeting platform native toolkits as one can get.
Rust codebases extend in size and scale to larger teams fundamentally better than C++ / C. Rust offers more leverage in building ambitious system software.
Since you mention Qt, imagine writing all of Qt in x86 assembly, vs. C++. "There's not particular reason this isn't doable." C++ to Rust is a similar jump. No silver bullets; just leverage.
Cross-platform toolkits — especially those aiming to abstract over native UI/UX patterns — are an ambitious, if not Sisyphean domain. Qt was about the best we could do in the C++ era, but a new era has dawned.
> “Abstracting” away the native GUI/UX seems to be a common pitfall for junior devs
I would like to know more about what you mean here; my description of a "virtual UI" that you bind to from the native toolkit is an abstraction to the UI - but it's not an abstraction like Flutter which tries to merge all native widgets into abstracted widgets. My concept still requires you to write multiple native entry points using the UI kits of the target platforms.
` (GTK entry || Cacao entry || Win entry) => Virtual UI => application logic `
The idea is that the virtual UI would be an in-memory representation of the UI (have virtual buttons, labels, etc). It would be the job of the entry to correctly represent/bind to that virtual UI with the relevant presentation tool kit. The output binary would be specialised to the platform/UI kit used in the source entry point.
It seems sensible on the surface to decouple the UI from the native presentation as it minimizes the requirements of the native side to constructing the UI and binding to the virtual UI - but I would love to hear your thoughts.
I have not tested this architecture outside of web development but I imagine adding new UI targets (like web assembly, QT, etc) would be easier as it wouldn't require any changes to the virtual UI or application logic and would be a matter of creating a new entry point representing the UI for the new target.
> then they learn why Qt exists
Does QT feel native on MacOS, Windows and Gnome?
> Yes it is [talked about]
Could be my personal echo chambers talking here - but multithreading is almost never spoken about and/or often intentionally disregarded in modern web/electron applications.
It sucks because so many applications are written using Electron or other similar web wrappers.
> there isn’t a particular reason this hasn’t been doable in C/C++ since forever - Rust isn’t some silver bullet
Not dismissing this, I was more impressed that Rust offers a thread safety guarantee through its ownership model making it interesting from a contributor scalability standpoint.
I was thinking that it might make it easier to have more engineers working on a high performance GUI project because it would be significantly harder to break.
As an example; I could imagine if a company assigned a team of TypeScript/JavaScript developers with different experience levels onto a GUI project written in something like Go, there would be a lot of thread safety issues and seniors would spend a lot of time combing PRs for thread safety issues.
Rust, while perhaps not as simple from a syntax/types/symbols standpoint, offers an interesting development modality for these sorts of projects. I would expect that it would result in a more hands off contributor experience.
> Electron is about as far removed from the philosophy of targeting platform native toolkits as one can get.
Sorry I wasn't describing Electron as targeting platform native decorations - just that it promises an OS agnostic UI framework (write once run anywhere) at the expense of a diminished native experience and poor performance.
My point was that it might be interesting to explore the idea that a multi-entry native toolkit application fulfils the same "write once run 'anywhere'" promise but without the downsides.
You can write your core application logic once and share it, but you need to have the interaction with the actual UI/window manager be per-platform. The reason electron apps are so bad on Mac is not that the core application logic is bad, it's that a whole bunch of basic Mac platform behaviors are broken.
"modern" cross platform UI toolkits are no better than Java. To paraphrase Ford: "you can do any platform you like, as long as it's windows".
[edit: to be very clear, I include "catalyst" in the cross platform toolkits that make noticeably worse apps on Mac. Trying to share a single interface "language" for different platforms just leads to what is at best mediocre UI.]
And why wouldn't a hybrid approach work? I.e. the majority of the code using the cross platform toolkit, and a small amount of code per platform using the native API.
I agree with your statement about modern toolkits being no better than Java, but Java is pretty good. I’d have no problem starting a new project with it today.
All that said, I’d much rather have a well written native application than a well written cross platform application.
Tangentially related, I'd to dabble in Rust at some point but the syntax and memory management leave me trepidatious, and I'm not sure that it'd be the tool I reach for when developing apps with UIs… from a distance it feels better suited for CLI tools, back ends, and the nuts'n'bolts parts under the hood of UI apps. In comparison it makes some tradeoffs but I really enjoy writing UI apps in Swift (albeit in UIKit/AppKit — SwiftUI needs more time in the oven).
Assuming your trepidation is because memory management is somehow more manual in Rust I would argue that it's actually not. This isn't something I'm saying because I want to convince you to use Rust; I'm actually of the opinion that Rust doesn't give you enough direct control of memory allocation and has iffy support for custom allocators on top.
Rust's memory management is much more like a garbage collected language in practice, hence why I consider it too indirect.
Instruction for building apps in AppKit has always been kind of spotty. When I first started learning it alongside Objective-C in the 2000s, the best a beginner could really do was sift through random blogposts and mimic patterns seen in FOSS Mac apps. The best resources at that point were probably the various books on the topic (such as the Big Nerd Ranch Cocoa books I'd seen recommended frequently) but at that point I was a broke teenager so buying books was off the table.
I would like to at some point build a one stop shop for learning all the most pertinent parts of building a Mac app with AppKit and Swift, but that takes a lot of time… if it happens it'd probably be when I'm inbetween jobs so I can dedicate the resources required to make such a thing good.
AppKit is first because this was extracted from a cross platform GUI library I was building years ago, and it’s just less cumbersome to iterate on.
Five years would shock me. I’d say more like ten. It’s gonna take a huge concerted effort to get rid of objc in macos, and idk if it’s worth it
Oracle ditched it a long time ago [0]
> What is JetBrains using for its sophisticated GUIs? Is it just Swing?
They use custom Swing components [1]
0: https://www.infoworld.com/article/3261066/javafx-will-be-rem...
1: https://plugins.jetbrains.com/docs/intellij/user-interface-c...
This is, incidentally, how the servo bindings to core-foundation work (I prefer those bindings where there is overlap).
Servo bindings: https://github.com/servo/core-foundation-rs
Other crates of interest on this topic: - https://crates.io/crates/objc - https://crates.io/crates/block
Nope, retain on create/etc and release on drop happens automatically.
The downside is that code written against this api will not work on any other platform.
But more than likely it's just a reference to Apple's Cocoa api.
Never seen Portlandia, so no. Just a Cocoa pun!