Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

so the GC isn't optional in D?


It is, but the standard library uses it so you have to avoid them if you want no GC.


That's changing. The standard library is almost entire GC-free now.


That's a little adventurous. std.algorithm is known to only have one function which allocates.

The rest of Phobos is being looked at, but to this point I don't think it has been combed thoroughly enough to say "almost entire."


Yeah. The "almost entire" applies to std.algorithm. How much allocation goes on elsewhere depends on what module you're talking about. Some definitely avoid it, whereas others definitely require it. That will be (and has been) changing though. The main thing is probably going to be making much heavier use of output ranges rather than automatically allocating arrays/strings. We'll get there though, because there's clearly a lot of interest in doing so, and there's no fundamental reason why we can't.


I'm not sure where you got that idea but that's not true. The standard library make heavy usage of the GC. There is talk of implementing ARC to replace or supplement the GC and the standard library will most likely soon start using output ranges to avoid forced GC allocations in many cases but that hasn't happened yet.


From Wikipedia:

"Memory is usually managed with garbage collection, but specific objects can be finalized immediately when they go out of scope. Explicit memory management is possible using the overloaded operators new and delete, and by simply calling C's malloc and free directly. Garbage collection can be controlled: programmers can add and exclude memory ranges from being observed by the collector, can disable and enable the collector and force a generational or a full collection cycle. The manual gives many examples of how to implement different highly optimized memory management schemes for when garbage collection is inadequate in a program."

I wonder if the GC is stop-the-world.


From http://dlang.org/garbage.html :

> Stopping all other threads than the thread currently trying to allocate GC memory.


In D the garbage collector is stop-the-world and conservative, last I looked.


not as far as I know. while having garbage collection was an asset when java was created, currently with ubiquitous RAII usage in c++ it's just a hindrance.


The GC is optional in D (parts of the standard library use it so you'd have to avoid those). D uses RAII when it makes sense too.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: