4 ms·
Whether GC improves productivity is a strong claim that needs a proof. I have yet to see such a proof. So far my experience has been that (nondeterministic) GC
by pkolaczk 4y ago
Whether GC improves productivity is a strong claim that needs a proof. I have yet to see such a proof.
So far my experience has been that (nondeterministic) GC is only a productivity improvement over languages with manual memory management like C, but a productivity degradation over languages with deterministic automatic memory management like C++ and Rust. GC manages only memory, while in the latter case, you get automatic management of resources of any type, which can be a huge productivity boost if you use it to your advantage.
- pjmlp 4y agoDo you want an example for C++? Lock free data structures are PhD level skillset unless there is some kind of tracing GC algorithm being used. Also RAII is great and all, yet there lots of ways to get it wrong. Badly implemented destructors, missing virtual destructors in hierachys, throwing exceptions on destructurs, not using handle types on heap allocated data, incorrect pairing of allocators.
- pkolaczk 4y agoLock-free data structures is a 0.001% niche, which can be implemented as libraries by experts and then used without any trouble by an average Joe programmer. An average Joe wouldn't get the implementation of them right even in a GC language anyway. Also, in those niche cases, GC is available as an option. But you should not optimize the language for the niche use case. > Badly implemented destructors, missing virtual destructors in hierachys, throwing exceptions on destructurs, not using handle types on heap allocated data, incorrect pairing of allocators. Those seem to be more specific problems with C++ rather than RAII. Rust has none of those.
- pjmlp 4y agoThe ongoing issues with Drop trait stabilization show otherwise. Having a GC is an option alongside the other ones, an option that both Epic and Microsoft think it is worth enough money to spend development resources on. And Google as well, actually, as Chrome uses a C++ GC, seen as way to fix security issues, Olipan.
- pkolaczk 4y agoGC as an opt in, next to to RAII - so you can use it when you need it, that's fine. But it is a productivity issue when the only way to manage memory is non-deterministic GC, e.g. like in Java or Go.
- pjmlp 4y agoThat was the original question, why there are GC implementations for C++. Every language with a GC is distinct, and should be properly analysed instead of putting all into the same box.
- patrick451 4y agoDemanding proof is a cop out. From microservice architectures to line length limits, there's no proof for basically any engineering decisions we make daily.