4 ms·
The borrow checker is what is being referred to and has no runtime overhead. Now, an environment without a GC will use ref counting sometimes but it will regar
by epage 7y ago
The borrow checker is what is being referred to and has no runtime overhead.
Now, an environment without a GC will use ref counting sometimes but it will regardless of C, Rust, or C++
- gmueckl 7y agoReference counting has well known issues that are independent of the programming language: - can't deal with circular references without user intervention - storing the reference counter is hard: either it clobbers a whole cache line or it ruins memory alignment - atomic reference counting has the potential to utterly ruin runtime performance unless it used extremely carefully
- steveklabnik 7y agoThe borrow checker does not use reference counting.
- littlestymaar 7y agoI'm pretty sure you are confusing Rust (borrowck, done at compile-time, no runtime overhead) and Swift (where every object is reference-counted, with some, sometimes big, overhead).
- pjmlp 7y agoIn Rust GUI code is quite common to have Rc<RefCell<>> scattered across all widgets callbacks.
- littlestymaar 7y agoI assume you're talking about GTK or Qt? AFAIK they are the only viable options for Rust GUI at the moment, but their paradigm doesn't fit well with Rust ownership and you need to use ref-counting everywhere as you said. I don't think the problem is inherent to GUI in general though.
- pjmlp 7y agoIt is, because Rust ergonomics for self referencial structs from closures require this type of dance. And when one cares about performance, creating/destructing hundreds of instances per frame like on reactive approaches, it isn't the best use of CPU cycles.