Hacker News new | ask | show | jobs
by kitsunesoba 1126 days ago
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 iDevices.

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

3 comments

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

From the bits of Rust code I've seen, it seems like while memory management isn't exactly manual, it needs to be given a fair amount of thought, what with borrow semantics and such. When writing Swift I very infrequently have to give it any thought at all, beyond avoiding retain cycles (which is usually as simple as using weak references to self in closures).
There's no obligation to pass everything in references. You can wrap most things in Box/Rc/Arc and move on with your life.
But why bother using Rust then?

If you are going to use it like a garbage collected language, you would be better served by one of the slew of other languages with the same features but which are easier to use. The memory management is what sets Rust apart.

More tangential, is there a good, in-depth resource for learning how to build an app in AppKit w/ Swift?
Unfortunately I can't point you at a single comprehensive resource.

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.

Gotcha, thanks for the reply. I think you'd have the market on this domain cornered if ever you'd produced a comprehensive text since its very much still blog posts and reading extant code.
Author here. :)

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.