Hacker News new | ask | show | jobs
by adrianratnapala 3537 days 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.

3 comments

And C++ is all about choice trade-offs.

Put very simply: do your choice for your problem and deal with its consequences.

Nobody says GC has no advantages, the claim is that its disadvantages don't always offset them.
The way C/C++ get around the implicit ownership of const char * is everyone copies data around.