Comment by cogman10

4 days ago

> Garbage collection does not solve memory leak problems

It solves a class of memory leak problems which are much harder to address without the GC. Memory lifetimes.

It's true that you can still create an object that legitimately lives for the duration of the application, nothing solves that.

But what you can't do is allocate something on the heap and forget to free it. Or double free it. Or free it before the actual lifetime has finished.

Those are much trickier problems to solve which experienced C/C++ programmers trip over all the time. It's hard enough to have been the genesis of languages like Java and Rust.

I do wonder then how difficult it would be to mod games written in D

  • I don't think D has a "must use GC" mode, so probably easy to hit a footgun. It's the footguns that make things hard (IMO).

    • There is no "must use GC" mode, as far as I'm aware, but the footguns you describe only exist if the programmers opt-out of the GC. It's somewhat similar to using JNI/FFM in Java: it's possible to escape the safety of the VM. Though it's much easier to do so in D.