The purpose of D (GC rant, long)

Dave Dave_member at pathlink.com
Thu Oct 26 18:37:41 PDT 2006


Sean Kelly wrote:
> Walter Bright wrote:
>>
>> Then I began to think about why C++ was so complicated. I eventually 
>> began to realize it's because of explicit memory management. Have a 
>> gc, and suddenly you can make a language with even greater power that 
>> is much, much simpler.
> 
> After using D for a bit, I came to the same conclusion.  That isn't to 
> say you can completely forget about the cost of reallocations or data 
> ownership, but having a GC simplifies the things that should be simple, 
> without creating additional complexity elsewhere.
> 
>> For one example, you cannot do array slices in C++ without 
>> considerable agony. In D, they are easy as pie.
> 
> True enough.  I have a slice class I use in C++ for specialized purposes 
> (a compiler, for example), but dealing with the memory ownership issues 
> are just too much of a headache for apps where data doesn't have such a 
> predictable lifetime.
> 
>> P.S. It *is* true (before D) that gc based languages are slower than 
>> C/C++. The conventional wisdom says that this is caused by the gc. 
>> This simply is not true, the slowness is usually caused by lack of 
>> expressiveness in the language (Java) or dynamic typing (Python, 
>> Javascript, etc.).
> 
> I think another issue is that garbage collection *can* cause a 
> noticeable stutter in user applications which pay no attention to memory 
> management, and it's easy for someone to point at that hitch and 

It's called "The path of least resistance" <g> When even a good programmer who knows better is in a 
hurry (and when are they not? ;)), they'll abuse the heck out of the heap because it's more 
expedient, and the end result still makes it past QC. Pretty soon you have this largely sub-optimal 
program made up of many small, somewhat sub-optimal pieces.

D though at least gives us 'delete' as well as some control over the GC.

As an aside, academia moving away from explicit memory managed languages in their curriculum's is 
probably producing quite a few programmers who know very little about memory management and how it 
can effect performance.

> proclaim that garbage collection itself is slow.  People seem to like 
> the straw man argument for some reason.
> 
> 
> Sean



More information about the Digitalmars-d mailing list