Hacker News new | ask | show | jobs
by lll-o-lll 1203 days ago
People do say that Swift is slow though, and it has a whole bunch of optimisations to ensure the RC is elided whenever possible.
1 comments

There are two differences from Swift:

1. You don't need to refcount everything. In Swift objects have to be refcounted and heap allocated. In Rust you only use it selectively in cases where shared ownership is really necessary, and otherwise still have an option of using exclusive ownership, value types, etc.

2. You can still borrow Rc's contents locally and use it as a plain reference, so hot loops and leaf functions don't pay the price. Often you may need to touch the refcount only once when building a data structure or passing data to a closure, and then on use it via a temporary reference. In Swift the refcount is updated much more often, and there are only limited cases where ARC optimizer can skip it.