Right now, what's the most important for the success and adoption of D?

Daniel Keep daniel.keep.lists at gmail.com
Fri Sep 28 18:50:25 PDT 2007



Craig Black wrote:
>> Dynamic library support.  Without it, D executables are going to be
>> unreasonably large.  Imagine a large project like gnome or KDE implemented 
>> in only statically linked format.
> 
> Specifically what does D lack with regard to dynamic libraries?  I know it 
> can load DLL's at runtime.  Does it lack support for load-time dynamic 
> linking?  If this is the case, that is a very big problem.
> 
> -Craig 

Note: the following may be completely wrong :P

I am, by no means, an expert on this, but here's how I understand it:

Basically, there are two problems.  The first is that Windows uses DLLs.
 DLLs cannot import symbols from the host they're being loaded into.
This means that a D DLL cannot get access to the host's garbage
collector, and must run its own.

This is a *huge* problem because you now can't share memory between the
host and the DLL because the GC's are going to collect memory they can't
see.  If the DLL passes an array back to the host, that array could be
collected at *any moment* by the DLL's GC.

It gets more fun when you factor in threads: the D GC has to "stop the
world" when it collects.  But this means that the DLL GC can't stop the
host's threads from running and vice versa.  This means there's no way
for either host or library to safely collect garbage without potentially
crashing the other.  Yay!

On linux, the problem is one of codegen: the dmd compiler can't generate
position independent code, which is required for SO libraries.  I
believe that GDC is able to do so, however.  That said, I don't use
linux, so I could easily be wrong.

What was supposed to save us from this was DDL: it basically implemented
user-supported (as opposed to kernel-supported) dynamic libraries.
However, the maintainer has been very busy, and it's languished; I don't
think the current release compiles under D 1.0 yet.

I believe that one of two things need to happen for good dynamic library
support for D:

  1. Walter finds time to change phobos from a static library to a
     dynamic one, thus introducing us to the wonders of DLL hell on
     Windows because phobos tends to change with each new compiler
     release *and* add position-independent code gen to the linux
     compiler.

Or

  2. We all start to chip in and get DDL back on its feet.

Personally, I think 2 is the way to go :)

	-- Daniel



More information about the Digitalmars-d mailing list