News for hackers. Stuff that matters.
Re:Ask HN: Rust or Swift for system programming? by millstone on Monday July 04, 2016 @07:31PM (#12033559)
Which pointers? Here's all the different pointers I know of in Rust, and their equivalents in Swift:

Rc/Arc <-> class types

Raw pointers <-> UnsafePointer/UnsafeMutablePointer

References <-> inouts

Trait objects <-> Protocol objects

Box <-> indirect enum (arguably)

Did I miss any?

Of the core language features, protocol objects are the only case where Swift uses reference counting and Rust does not.

Re:Ask HN: Rust or Swift for system programming? by pcwalton on Monday July 04, 2016 @09:08PM (#12033853)
Swift doesn't have the borrow checker, which means that in order to ensure safety the expressiveness is really limited unless you use RC. That's why essentially all Swift code uses RC, and Rust code rarely does.

There's a big difference between technically having manual memory management and having it actually widely used and practical.

Re:Ask HN: Rust or Swift for system programming? by millstone on Monday July 04, 2016 @10:31PM (#12034082)
Yes, RC is the primary way to safely manage lifetimes of reference types in Swift. You can drop down to unsafe constructs to avoid RC overhead, and I sometimes do that in hot loops.

Using unsafe to improve performance is not unfamiliar in Rust either, though Rust gives you better tools for building safe abstractions around it.

Shared ownership is routine in UI programming - think event handlers, etc. These are the apps most commonly written in Swift. Does Rust avoid needing shared ownership for these types of apps? If so, how?