5 ms·
No it is not. The whole point of GC is to collect cycles and not think about ownership, while Swift and Rust require you to think about ownership. In Rust you
by oleganza 4y ago
No it is not. The whole point of GC is to collect cycles and not think about ownership, while Swift and Rust require you to think about ownership.
In Rust you do so via borrow checker or explicit Rc/Weak wrappers. In Swift you do that via additional weak annotations (strong being the implicit default).
- Ygg2 4y agoGrandparent is correct. Reference counting is a garbage collection mechanism. In same way a bubble sort is a sort. It doesn't care about ownership either. Apart from some Swift specific optimizations iiuc. Full GC I mentioned is more of mark and sweep variety.
- furyofantares 4y agoAlright, malloc/free is also garbage collection then.
- Ygg2 4y agohttps://en.wikipedia.org/wiki/Garbage_collection_(computer_science) https://en.wikipedia.org/wiki/Garbage_collection_(computer_s... See Reference counting. Note lack of malloc/free.
- mattgreenrocks 4y agoRef counting is considered GC (despite the colloquial definition excluding it) because RC handles the same problem domain as full GC, even with drawbacks around cycles. malloc/free, on the other hand, are just ways to allocate and release memory. They're too low level to be garbage collection. See this excellent comment: https://news.ycombinator.com/item?id=32277088 https://news.ycombinator.com/item?id=32277088
- pjmlp 4y agoI advise some self education in CS contents regarding GC. You can start here, https://gchandbook.org/ https://gchandbook.org/ https://www.udemy.com/course/essentials-of-garbage-collectors https://www.udemy.com/course/essentials-of-garbage-collector...