DMD vs. GDC vs. LDC

Compiler ConstructionDDmdGdc

Compiler Construction Problem Overview


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.

Compiler Construction Solutions


Solution 1 - Compiler Construction

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.

Solution 2 - Compiler Construction

  1. Significant drawback of DMD is shared library deficiency:
  1. I personally was surprised that GDC supports D2, but https://bitbucket.org/goshawk/gdc/wiki/Home">they say it does:
  • D1: 1.067
  • D2: 2.053

  1. LDC definitely seems to be scarcely maintained: http://www.dsource.org/projects/ldc/wiki/PlatformSupport">"D2 is working on x86-32 Linux only". To me, it's a showstopper issue.

  2. While searching for LDC I've found one more compiler (?!): https://github.com/azizk/dil/">dil</a>;. 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.

Solution 3 - Compiler Construction

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

Solution 4 - Compiler Construction

DMD is used for development because it compiles faster for production u can use LDC or GDC all of D language compilers use the same frontend but they differ on backend

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFritzView Question on Stackoverflow
Solution 1 - Compiler ConstructionTrass3rView Answer on Stackoverflow
Solution 2 - Compiler ConstructionvinesView Answer on Stackoverflow
Solution 3 - Compiler ConstructionJustinView Answer on Stackoverflow
Solution 4 - Compiler ConstructionAirbus5717View Answer on Stackoverflow