C++, D: Dinosaurs?

Walter Bright newshound1 at digitalmars.com
Sat Nov 8 21:06:27 PST 2008


Tony wrote:
> Please clarify for me the mem mgmt of D: is the garbage collector optional 
> or not? Just allowing me to replace "getmorecore()" or something like that 
> and then having the collector on top of that is unacceptable to me. I think 
> you may be saying that dynamic memory is in every program, which again is 
> not acceptable to me.

You can pretty much avoid all gc in D by doing your allocations using 
malloc/free and overloading operators new and delete for your classes. 
Some language features rely on gc, like dynamic closures, array 
concatenation, and the built-in associative arrays, but those features 
need not be used.


> Really, memory control is a key issue when choosing a language for me 
> anyway. I require that level of closeness to the hardware. Anything less is 
> too 4GL-like for me.

I understand how you feel. For a very long time, I felt the same way. I 
wanted the control. I thought GC was for below average programmers who 
couldn't handle memory allocation. I worked with a Java implementation 
for a while when Java first came out (building a native Java compiler) 
and came to realize the basis of my beliefs were unfounded.

GC has some compelling advantages:

1. GC programs can be faster

2. GC programs can use less memory

3. GC programs can be guaranteed to be memory safe

4. GC programs are faster to develop and have fewer bugs



More information about the Digitalmars-d mailing list