3 ms·
Using GC in C++ is rather simple, just use a GC-powered allocator and you don't need to call `delete` anymore. But GC just doesn't matter so much. Many forget-t
by luikore 13y ago
Using GC in C++ is rather simple, just use a GC-powered allocator and you don't need to call `delete` anymore. But GC just doesn't matter so much. Many forget-to-delete or delete-too-early problems can be solved by memory analyzers. There are actually very few bugs that adding a GC can solve.
- rwmj 13y agoThis is why I said "true" garbage collection. Conservative GC ain't real GC. GC isn't about eliminating bugs -- use valgrind for that -- it's about increasing programmer productivity, along with all the other features missing from C++ but present in modern strict strong-typed functional languages.
- luikore 13y agoConservative GC is real GC, it's just the tracing set happens to be the stack. And I don't see why you can't use non-conservative GC for C++ allocators. It only requires some work for read/write barriers. GC is all about using `malloc/new` without thinking `free/delete`. With modern C and C++ there are a lot of mechanisms for that (passing values, auto_ptr and shared_ptr for example). In many cases a C++ programmer doesn't need to think about `free/delete` either, and in some cases the non-determinism of GC decreases the productivity too.