Idiomatic D using GC as a library writer

bachmeier no at spam.net
Sun Dec 4 13:42:50 UTC 2022


On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote:
> Dear dlang community.
>
>
> I am unsure about what idiomatic D is.

Idiomatic D code produces the correct result, it's readable, and 
it's easy for others to use.

> Some of the Dconf talks tells people just to use the GC, until 
> you can't afford
> it.

"can't afford it" in what sense? Pauses for garbage collection 
are one thing, overall runtime performance is something 
completely different. Avoiding the GC won't magically make your 
program faster.

> If there are documents that describes what idiomatic D is then 
> I would appreciate it.
>
>
> So my questions are:
>
>
> What are your thoughts about using GC as a library writer?

Depends on the library, but most of the time it's best to use it. 
D's main problem at this point is a lack of high-quality, 
easy-to-use libraries - not libraries that use the GC.

> If you wan't to include a library into your project aren't you 
> more inclined to use a
>
> library which is gc free?

The moment I have to think about memory management, I start 
looking for a different library. I suppose there's nothing wrong 
if a library avoids the GC internally (since that won't affect 
me). The GC has never caused problems for me. It has made my life 
easier.



More information about the Digitalmars-d-learn mailing list