4 ms·
ObjC's and Swift's ARC (Automatic Reference Counting) is not just dumb "reference-count everything", the compiler does static lifetime analysis and removes redu
by flohofwoe 3y ago
ObjC's and Swift's ARC (Automatic Reference Counting) is not just dumb "reference-count everything", the compiler does static lifetime analysis and removes redundant refcounting operations.
In theory at least this may actually yield better results than in C++ and Rust where refcounting is implemented as stdlib feature and optimizations rely on "zero cost abstractions" late in the compilation process.
But even ARC needs a lot of handholding and manual tweaking if performance matters.
- littlestymaar 3y agoGranted, it probably has improved a lot since 2016, but I didn't have an occasion to update my knowledge about Swift since then. Back then you definitely ended up with tons of pointless ARCs, but in fairness the compiler was brand new at that point so no wonder it wasn't good at optimizing stuff away.