← Back to context

Comment by WalterBright

3 months ago

> is it now natural to mix borrow checking and garbage collection?

D is as memory safe as Rust is, when you use the garbage collector to allocate/free memory. If you don't use the GC in D, then there's a risk from:

    * double frees
    * memory leaks
    * not pairing the allocation with free'ing

Those last 3 is what the borrow checker handles.

In other words, with D, there is no point to using the borrow checker if one is using D's GC for memory management.

You can mix and match using the GC or manual memory allocation however it makes sense for your program. It is normal for D programmers to use both.

> D is as memory safe as Rust is, when you use the garbage collector to allocate/free memory.

Does D also protects against data race?

(I couldn't find an obvious answer after a bit of research, but I might have overlooked something)