6 ms·
One difference is optimization. Rust's Arc is runtime-only, while Clang's ARC is understood by the compiler and optimizer. This allows eliding balanced mutation
by ridiculous_fish 7y ago
One difference is optimization. Rust's Arc is runtime-only, while Clang's ARC is understood by the compiler and optimizer. This allows eliding balanced mutations, and also weird ABIs - functions which return a +1 object, or functions which accept a +1 object. See Arc#Optimization [1].
More generally there's an ABI. While to Rust "Arc is just another tool", reference counting is deeply pervasive on iOS and macOS. You would not attempt to pass a Rust Arc to C, and expect something useful to happen. But Clang's ARC works well with C, and Swift, and with ObjC and even with ObjC-pre-ARC. This isn't a critique of Rust, just reflecting different priorities.
1: https://clang.llvm.org/docs/AutomaticReferenceCounting.html#optimization https://clang.llvm.org/docs/AutomaticReferenceCounting.html#...
- pjmlp 7y agoThose compiler optimizations need some work I guess. https://github.com/ixy-languages/ixy-languages https://github.com/ixy-languages/ixy-languages
- tom_mellior 7y agoPersonally, I appreciate you posting this link once, but seeing it this many times gets tedious.
- pjmlp 7y agoUnfortunately it is hard to give an answer were all advocates of "Swift ARC performance" are able to read, thus urban myths keep being spread. ARC makes sense given Objective-C compatibility, as otherwise a layer similar to RCW on .NET for dealing with COM/UWP would be needed. And Objective-C only dropped its tracing GC, because it was too unstable while mixing GC enabled frameworks with classical ones, while making the compiler automatically call retain/release would provide better productivity without being unstable.
- tom_mellior 7y agoI understand the urge to reply in multiple places. I think it would be better to write up some more detailed reasoning, like you did here, and link to this from multiple subthreads. Better than just repeating the same ixy link with a new snide comment each time.
- pjmlp 7y agoMakes sense.
- mpweiher 7y ago> too unstable while mixing GC enabled frameworks with classical ones Actually, you couldn't mix them. The GC simply never really worked properly.
- pjmlp 7y agoTrue, however Apple's documentation suggested otherwise, that it was possible "with care". But as you say, it never worked properly.
- mpweiher 7y agoI think what you are referring to is "mixed mode" frameworks, which were able to work in both GC and RC environments. You had to do a bit of work to get that. Which is similar but not quite the same thing. Mixing pure GC and pure RC frameworks was never possible. In fact, I think there were some flags and the (dynamic) linker would balk.
- ridiculous_fish 7y agoWhich urban myth do you see being spread in this thread?
- pjmlp 7y agoARC outperforming modern tracing GCs.