3 ms·
I agree with you, but I just want to point out that there are other seamless solutions to memory management like refcounting, used by for example GDscript (Swif
by TonyStr 2mo ago
I agree with you, but I just want to point out that there are other seamless solutions to memory management like refcounting, used by for example GDscript (Swift? Perl?). You definitely wouldn't consider this manual memory management
- yxhuvud 2mo agoNo, I would consider refcounting as variants of GC.
- ghusbands 2mo agoRefcounting is indeed a form of GC (and the languages that want to handle cycles then need an extra form of GC on top of it).
- frollogaston 1mo agoGC specifically means you leave unreferenced mem on the heap until it gets collected in one big sweep later.
- ghusbands 1mo agoYou're referring specifically to tracing garbage collection. When a reference count reaches zero, that garbage is collected, often recursively. Among programming language designers, ARC is considered a GC strategy. https://en.wikipedia.org/wiki/Garbage_collection_(computer_science) https://en.wikipedia.org/wiki/Garbage_collection_(computer_s... https://users.rust-lang.org/t/reference-counting-garbage-collection-and-rust/107728/24 https://users.rust-lang.org/t/reference-counting-garbage-col...
- vrighter 2mo agoif refcounting is gc, then c++ is a garbage collected language. It has std::shared_ptr
- frollogaston 1mo agoRefcounting isn't GC, but also C++ isn't a refcounted language. You could spam shared_ptr everywhere, but it's not designed for that and probably wouldn't be performant. And because of that, realistically all your libs take raw pointers, so you still have to unwrap your shared_ptrs then be back to managing ownership. Swift has refcounting built into the language and assumed everywhere. You could always use raw refs in Swift, but that's not the norm.
- worik 1mo agoNo E.g. in Swift the reference counting is automatic a d implicit In C++ it is manual and explicit
- frollogaston 1mo agoI wouldn't consider Swift manually managed, but also not GC. And not being GC has some practical implications like needing to break cycles yourself, so you need to at least be aware of ownership a little. It's like a manual transmission vs automated manual vs true automatic, AMT removes most of the work but still cannot be treated like full auto.
- TonyStr 1mo agoGood point, I like your formulation