Do you use D's GC?

Dukc ajieskola at gmail.com
Sun Aug 1 10:30:45 UTC 2021


On Sunday, 1 August 2021 at 08:54:05 UTC, Kirill wrote:
> It's interesting to hear do you use D's GC? Or do you use your 
> own custom memory management structure?

Often. I could avoid it but it's rarely worth it. Well, I do try 
to avoid heap usage in general when I can easily do so, but I 
don't often use RAII, let alone `malloc`/`free`. And even when I 
have done so, it's not so much for performance, it's for 
portability (through with Dylan Graham's LWDR I'm not sure I have 
to avoid GC for portability anymore).

>
> How performant is GC?
>
> The reason I'm asking is I'm planning to dive into 3D game dev 
> with D as a hobby in an attempt to create a game I dreamed of 
> since I was a kid. I'd like to know if GC is worth using at 
> all, or should I go with 100% manual memory management.
>
> Any opinion is appreciated. Thanks in advance.

Most people nowadays use an already made game 3D engine - You may 
well have heard of Unity and Unreal engine. While they do not let 
a game to be as performant as with a purpose-built engine, the 
fact that reasonably light 3D games have been made with them for 
ages speaks a lot.

Godot game engine is a great choice IMO, especially with D. It's 
fully open source, has a good D binding, and it has a better 
object model than Unity does. Binding here: 
https://github.com/godot-d/godot-d.

And yes, D GC is available with Godot. It's unlikely you'll have 
problems with it, as the game engine takes care of the heavy 
crunching - you generally write only the scripts.

You may also consider Dagon 
(https://code.dlang.org/packages/dagon). As a much smaller 
project it's going to be harder to use it than Godot, but if you 
want a pure D game engine you might consider it. It's still 
definitely an easier route than writing your own engine.


More information about the Digitalmars-d mailing list