Live data from Hacker News

macOS Apps in Rust

github.com

11–20 of 89 posts

Re: macOS Apps in Rust

#11
post #9

Is... the name a Portlandia reference?

It could be a Portland reference. The city had a gourmet chocolate shop called Cacao that served "drinking chocolate" from 2005 until 2020. I know because I went in there after getting lost and drenched in a Portland February, and the staff there were kind enough to bring me towels and let me wait out the downpour while I sipped chocolate.

But more than likely it's just a reference to Apple's Cocoa api.

Re: macOS Apps in Rust

#12
post #11
post #9

Is... the name a Portlandia reference?

It could be a Portland reference. The city had a gourmet chocolate shop called Cacao that served "drinking chocolate" from 2005 until 2020. I know because I went in there after getting lost and drenched in a Portland February, and the staff there were kind enough to bring me towels and let me wait out the downpour while I sipped chocolate. But more than likely it's just a reference to Apple's Cocoa api.

Am I missing something, is the name/reference just "cacao"? Many languages spell cocoa that way, so I would take the name as cocoa-but-exotic or cocoa-but-foreign.

Re: macOS Apps in Rust

#14

Pretty cool project, seems like it's becoming more realistic to write cross platform native desktop applications with OS-specific GUIs in Rust. 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…

> 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.

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.

Re: macOS Apps in Rust

#15

Interesting to see that AppKit is fully supported before UIKit, usually it's the reverse (if AppKit is supported at all). I suppose it kind of makes sense… the case for sharing a Rust core across platforms is stronger on macOS, because on iOS the optimizations you're trading away (such as the native network stack scheduling requests from apps to fire while the antenna is already awake) have a bigger impact on iDevice…

> Tangentially related, I'd to dabble in Rust at some point but the syntax and memory management leave me trepidatious [...]

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.

Re: macOS Apps in Rust

#16
post #5

Earlier quoted context omitted.

The GUI bindings are usually the hard part.

Speaking of, does anyone know how Qt bindings for Rust are these days? Last time I looked, there were several awkward Rust APIs for Qt, suffering in part from the fact that Qt's API is inheritance-based.

I think it's pretty difficult mapping the Qt memory management model to Rust, for the same reason we haven't seen working Golang bindings for Qt either. I have some experience with the Python bindings (PySide or PyQt) and both of them use pretty extensive wrapper generator frameworks specially developed for the task (SIP in the case of PyQt, Shiboken in the case of PySide), coming up with something like that is not an easy task at all. And Python is a language that was pretty much intended to act as a foreign function wrapper around low-level languages, while Rust & Golang are not primarily intended to be wrappers for other languages.

Re: macOS Apps in Rust

#17
If you use the Cocoa API with ObjC or Swift, you get Automatic Reference Counting (ARC), generated by the compiler. I guess with this you'd have to retain / release your objects manually again?

Re: macOS Apps in Rust

#19

If you use the Cocoa API with ObjC or Swift, you get Automatic Reference Counting (ARC), generated by the compiler. I guess with this you'd have to retain / release your objects manually again?

Rust has ARC too so I very much doubt it.

Re: macOS Apps in Rust

#20

Pretty cool project, seems like it's becoming more realistic to write cross platform native desktop applications with OS-specific GUIs in Rust. 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…

You can't write good UI apps with cross platform code. The basic idioms of each platform are different.

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.]

Post reply on HN