2 ms·
> Languages with GC-managed runtimes (Java, C#, Go, Swift, et. al.) Swift does not have a GC managed runtime in the same sense as the other languages you liste
by ninkendo 1y ago
> Languages with GC-managed runtimes (Java, C#, Go, Swift, et. al.)
Swift does not have a GC managed runtime in the same sense as the other languages you listed [0], it’s basically a bunch of refcounts inserted by the compiler, with similar performance characteristics to Arc in Rust or shared_ptr in C++. (For classes, at least. Structs are value types and stack-allocated.)
[0] Yes, automatic refcounting is a form of garbage collection, but Java/C#/Go use tracing GC’s and not direct refcounting, whereas with Swift it’s more like the compiler is wrapping all objects in a shared_ptr for you, and so destruction is explicit and happens at exact points.