DMD vs. GDC vs. LDC
DMD is the reference implementation, the backend and frontend are open source. The code generation quality is not that overwhelming.
GDC and LDC are both based on the DMD frontend so it might take some time until a new version of the frontend is merged in.
Since the backends they use are very mature and good the quality of these compilers mainly depends on the glue code which connects frontend and backend.
LDC and GDC are still developed actively, but mainly by just a few guys.
All in all they could use some manpower.
- Significant drawback of DMD is shared library deficiency:
- on Windows
-
on Linux
- I personally was surprised that GDC supports D2, but they say it does:
- D1: 1.067
- D2: 2.053
- LDC definitely seems to be scarcely maintained: "D2 is working on x86-32 Linux only". To me, it's a showstopper issue.
- While searching for LDC I've found one more compiler (?!): dil. I haven't tested it yet, but at least it's currently maintained. I'll research more on this topic ASAP. EDIT: As it was pointed out in comments,
dil
isn't close to a somewhat complete state for now — it is only able to parse the code and generate documentation from sources.
As of February 2012, it seems that LDC is not really a usable option (at least on Debian).
For example, consider the first program in the D book:
import std.stdio;
void main(string[] args)
{
writeln("Hello, world!");
}
This will fail to compile with LDC on my system:
hello.d(24): Error: module stdio cannot read file 'std/stdio.d'
The same is true of the first program at dlang.org:
import std.stdio;
void main() {
ulong lines = 0;
double sumLength = 0;
foreach (line; stdin.byLine()) {
++lines;
sumLength += line.length;
}
writeln("Average line length: ",
lines ? sumLength / lines : 0);
}
This is because my LDC does not support Phobos--the current D runtime library. It looks like it is possible to build a D2 version of LDC, including Phobos, but that is not the way it ships on Debian at least.
GDC, and of course DMD, both compile the above just fine. It looks like GDC is quite up to date (DMD released 2.057 two months ago and GDC supports it now).
For me, GDC was the obvious choice because a simple 'apt-get -V install gdc
' brought in both the compiler and the Phobos runtime with no problems (tested on Debian unstable).