Comment by e12e

2 months ago

> (...) for a prototype of something I'll eventually rewrite in C++ at work.

> (...) realized (with the help of some people on the D discord) that the garbage collector is fine for my needs.

Do you envision linking in a garbage collector in your eventual c++ rewrite?

I'm open to it but I don't know enough about the options, other than the Boehm GC. If people know of good GC-in-C++ options, I'd love to hear about them.

In my area (numerical methods and computational geometry), I do not need anything to run in real or soft real time. The GC pauses aren't a concern. In which case, there is no real performance concern other than what I mentioned about the pauses being effectively single-threaded (my understanding... maybe this isn't exactly right). But this is supposed to be improved at some point, so whatever. Not having to explicitly think about memory management is a pure win.

On the other hand, my understanding is that using a GC in C++ could confuse things like Valgrind and ASan. Converting the entire codebase to use a GC is infeasible; so, if it made things more difficult for others by making these tools harder to use, it would be a nonstarter. But maybe this is just an imagined difficulty.

Another option is to just implement some scoped allocators. Everything I'm working on at the moment is "pure": some complicated operation applied to some fixed data. So, use an allocator to simulate GC within the scope of what I'm doing.

If anyone has thoughts here I'm definitely interested to here. Not that I'm looking forward to a C++ rewrite. :`(