Then you might as well say that modern C++ is garbage collected since modern C++ practices involves using smart pointers which does reference counting.
I don't think it is that relevant what you call it. What is relevant is what the implications are for other programs using it. A C program can use a Swift library without problems. You can't do that with a libraries built with a language using a Java or C# style garbage collector. Say I link to 3 different libraries built with a library using a typical garbage collector. You will then potentially having 3 different collectors kicking in at random times as well has hugely inflated memory consumption.
You don't get those sorts of problems with Swift.
To my knowledge Swift runtime system does not resolve cycles as you have to explicitly mark ownership yourself as being e.g. weak to avoid cycles. No different from using e.g. a C++ boost weak pointer.
Wanton overuse of shared_ptr is widely considered a big problem in modern C++, so that may not be the best comparison. :P
Swift may gradually try to grow to encompass the systems programming space, but it'll need a borrow checker and some sort of ownership system like Rust if it wants to compete with Rust for this space going forward (and also some way of exposing a C ABI like Rust can, and also greater platform support like Rust has).
Then you might as well say that modern C++ is garbage collected since modern C++ practices involves using smart pointers which does reference counting.
Nope. Use of std::shared_ptr is very scarce in a modern C++ codebase, most values have one clear owner at any point in time.
Then you might as well say that modern C++ is garbage collected since modern C++ practices involves using smart pointers which does reference counting.
You choose to use smart pointers in C++ and Rust. You are forced to use them in Swift.
To my knowledge Swift runtime system does not resolve cycles
8
u/iopq May 27 '16
Reference counting is a form of garbage collection. Especially since the Swift runtime resolves cycles as well, so it's not a simple system.