Sharing in D

Sean Kelly sean at invisibleduck.org
Thu Jul 31 13:37:06 PDT 2008


== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> Sean Kelly:
> > I am very much concerned that the "future of D" is
> > as a general applications language and that its systems language roots will
> > be left to rot.  And who needs another applications language, anyway?  The
> > world has a million of them.
> I think D is already partially unfit for being a system language, the runtime memory footprint is large; here it's
compared with Free Pascal:
> http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=dlang&lang2=fpascal

Agreed.  This is largely related to the generated TypeInfo, and is somewhat annoying.

> The GC can be disabled, but you have to carry it around in the executable anyway. The size of the executables
produced by DMD is large compared to the exes you obtain from stripped C. At the moment you can't run such things
on sytems with little RAM, as you can do with C.

It's actually possible to create a D application that doesn't have a GC at all.  Tango even supports
this out of the box.  The downside is that some language features rely on the existence of a GC
and won't work properly without one.  AAs are one example, and string concatenation is another.
However, a sufficiently diligent programmer could just not use these features, or the runtime
could be modified to explicitly support a GC-less application by making different assumptions
about what happens to discarded memory, etc.

> Regarding the hard real time systems, I think people there are scared of a GC (even if in practice it's not a problem).
So at the moment there are many things you can do with C that are a problem to do with D.

There are soft real-time GCs.  In fact, I believe there are hard real-time GCs as well--the Metronome
project at IBM springs to mind.  I would love to see such a GC for D, but I don't have the time and am
also not certain that it's possible to make a hard real-time conservative GC (which D currently requires).
I would be inclined to think that such a GC would be incremental and thus require more comprehensive
type info, but I haven't given the topic enough thought to be certain about that.

All that said, I believe it's entirely possible to write performance-critical code in D so long as the
programmer is careful about memory allocation.  And as Walter has said before, because even
malloc is not time-constrained the same goes for any use of dynamic memory--GCs just magnify
the issue.  Server apps in Tango, for example, don't allocate any memory at all once initialization
is complete.  This is why they tend to be so blisteringly fast.  It's also why Tango is designed the
way it is--not always super-convenient for run of the mill apps programming, but quite scalable
for high-end work.  By contrast, I'd argue that Phobos is the opposite.


Sean



More information about the Digitalmars-d mailing list