DMD vs. GDC vs. LDC

2019-03-08 17:29发布

问题:

What are the Pros/Cons of the different D Compilers? How is the performance and the standard compliance/D2 support? How well are debuggers supported? How good are the Error messages and is the IDE integration? How good is the 64 bit support? My thought so far:

DMD

  • Mature and well maintained
  • Only one platform, 64 bit support is not good
  • Not FOSS

GDC

  • Supports various platforms
  • Has very mature optimizations, so it's fast?
  • Out of date runtime?
  • GCC so a good debugger support?

LDC

  • Supports various platforms
  • LLVM, so it supports JITing?
  • Has very mature optimizations, so it's fast?
  • Not very well maintained?
  • Out of date runtime?

dead/not working

  • dang
  • sdc
  • MiniD - very, very nice, but not D (never claimed to be, though)

I'm thinking about targeting ARM and i think GDC is the tool of choice, but I'm not sure.

回答1:

DMD is the reference implementation. Only the backend is proprietary, the frontend is open source.
The code generation quality is not that overwhelming. x64 support is just a few months old though.

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.



回答2:

  1. Significant drawback of DMD is shared library deficiency:
    • on Windows
    • on Linux

  2. I personally was surprised that GDC supports D2, but they say it does:
    • D1: 1.067
    • D2: 2.053

  3. LDC definitely seems to be scarcely maintained: "D2 is working on x86-32 Linux only". To me, it's a showstopper issue.

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


回答3:

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