3 ms·
There is an advantage to universal GC: it can simplify interfaces. For example, in C every time a `const char *` appears in an API there has to be an implicit
by adrianratnapala 10y ago
There is an advantage to universal GC: it can simplify interfaces.
For example, in C every time a `const char *` appears in an API there has to be an implicit contract about who owns the string and how to free it. A language like Rust improves on this by enforcing such contracts, but the contracts still complicate every interface.
In a GC'd language you can just forget about these issues and just treat strings (and other immutable objects) almost as if they were ordinary fixed-sized values.
- steveklabnik 10y agoNobody says GC has no advantages, the claim is that its disadvantages don't always offset them.
- jdright 10y agoAnd C++ is all about choice trade-offs. Put very simply: do your choice for your problem and deal with its consequences.
- hackits 10y agoThe way C/C++ get around the implicit ownership of const char * is everyone copies data around.