GC in D and synadard library.

Mike Franklin slavo5150 at yahoo.com
Thu Dec 21 12:00:17 UTC 2017


On Thursday, 21 December 2017 at 10:49:46 UTC, Dan Partelly wrote:
>
> I started to look into D very recently. I would like to know 
> the following, if you guys are so nice to help me:
>
> 1. What is the performance of D's GC, what trade-offs where 
> done in design , and if a in-deep primer on efficient usage and 
> gotchas of the current implementation exists.

I've never independently measured it myself, so I can't say.

> 2. GC is never good enough. What are the current plans in this 
> area for D.

The -betterC feature come to mind.  Walter is trying to convert 
the DMD compiler's backend to D (It's still written in C-like 
C++; only the frontend is in D).  For reasons I don't quite 
understand, he wants to use -betterC and RAII:  
https://github.com/dlang/dmd/pull/7421#issuecomment-350874126

But the GC isn't required.  D is an extraordinarily powerful 
language with which you can work around just about any limitation.

https://wiki.dlang.org/Memory_Management
https://p0nce.github.io/d-idioms/#The-impossible-real-time-thread

> In general, please point me to the place where current work on 
> D is done.

Work on the D programming language is done primarily in 3 
different repositories:
DMD (reference compiler) - https://github.com/dlang/dmd
DRuntime (language runtime library) - 
https://github.com/dlang/druntime
Phobos (standard library) - https://github.com/dlang/phobos

> 3. I need to be able to run with GC totally disabled sometimes. 
> In the light of this:
>    - are there any features of core language which depend on 
> garbage collection ? (i.e unbound arrays, strings ..)

Yes, Exceptions, classes, dynamic arrays, and associative arrays 
come to mind.  But, keep in mind that there are always ways to 
word around this.

>    - are there any features from standard library which depend 
> on active garbage collection?

I'm not a big user of the standard library, but I believe most 
features of the standard library require the GC.

>    - Please point me to a list where there is an exhaustive 
> enumeration of which language features *and* library features 
> requires GC active. Looking at standard library docs I did not 
> seen markings which identify clearly and unequivocally what 
> requires GC active and what not.

I don't think such a list exists.  You can compile code with the 
@nogc attribute and the compiler emit errors if you attempt to 
use the GC.

The -vgc compiler option will also tell you where you have GC 
allocations.

> 4. Is Andrei Alexandrescu's book from 2009 on D still actual, 
> or the language evolution made it obsolete ?

I think there is still great information in that book, and Andrei 
is always a fun author to read.  However, "Programming in D" is 
probably the best place to start - 
http://ddili.org/ders/d.en/index.html

Some D books are currently on sale for $5 at Packt Publishing:  
http://forum.dlang.org/post/mbczecvrworfwacmzdep@forum.dlang.org

Mike




More information about the Digitalmars-d-learn mailing list