DMD vs. GDC vs. LDC

后端 未结 3 782
终归单人心
终归单人心 2021-01-31 07:39

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 mess

3条回答
  •  余生分开走
    2021-01-31 07:59

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

提交回复
热议问题