3 ms·
"Swift is slowly evolving into a formidable competitor to ... Rust" "Swift uses Automatic Reference Counting (ARC) to manage memory."
by k__ 6y ago
"Swift is slowly evolving into a formidable competitor to ... Rust"
"Swift uses Automatic Reference Counting (ARC) to manage memory."
- pjmlp 6y agoJust like many Rust code bases that are full of Rc<RefCell<>>, which don't get optimised away by the compiler.
- pornel 6y agoEven that poor case in Rust is already better than what Swift can do, because Swift's refcounting has to be atomic. Swift is too dynamic to prove objects don't escape threads, so it can't optimize that cost away. Rust's Rc/Arc can still selectively use borrowing, which guarantees the level of efficiency that in Swift may or may not happen depending on the optimizer. A borrowed Arc can often stay borrowed across many non-inlined method calls, which you're unlikely to get in Swift.