The purpose of D (GC rant, long)

Sean Kelly sean at f4.ca
Thu Oct 26 13:28:19 PDT 2006


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 
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