### yosupo's blog

By yosupo, history, 5 years ago,

Recently, I start to use dlang in competitive programming. There are 3 dlang compiler, "DMD", "LDC", "GDC".

In competitive programming, best choice is "LDC", but in many online judge, we can use only "DMD" or "GDC".

I hope to many online judge install "LDC", so I write this blog.

### Compiler compare

• DMD : Official compiler. Can use latest language version. Moderate Fast.
• LDC : based on llvm. Moderate new. Very Fast.
• GDC : based on gcc. Not new, Moderate Fast.

## How to install ldc

1. Go to github's release page https://github.com/ldc-developers/ldc/releases
2. Download ldc(If you use 64bit-linux, ldc2-1.2.0-linux-x86_64.tar.xz, in now)
3. Extract
4. ADD /your/download/path/ldc2-1.2.0-linux-x86_64/bin to \$PATH.

## How to use ldc

• Debug mode : ldc2 -d-debug A.d

• Release mode(and optimize) : ldc2 -O -release A.d

• +25

 » 5 years ago, # |   +10 LDC is indeed nice, it's almost bleeding edge in terms of language features, and makes fast executables. The main advantage of DMD is that it compiles fast, which matters when compiling locally. On the other hand, the compiled executable may perform sub-optimally compared to when using LLVM and GCC backends.Anyway, in my experience at setting and participating in programming contests, D compiled with DMD almost always performs between C++/GCC and Java if we look at similar solutions in these languages. And since the time limit is usually at least 2x Java time, DMD is a viable, if not the most optimal, choice.
 » 5 years ago, # |   0 Since I mainly use DMD, my command lines differ:(release) dmd -O -release -inline -boundscheck=off(debug) dmd -g -debug -unittestHere, -debug is useful for debug output. The following program can be debugged locally and then submitted without any changes:  auto a = readln.split; // read a line and split by whitespace debug {writeln (a);} // print the array of strings, but only in debug builds And -g keeps the stack trace meaningful when something goes wrong.On Windows, I have to add -L/STACK:268435456 to have enough stack available, similar to mingw/gcc.Also, there's ldmd2 executable in LDC which accepts options in the same form as dmd and provides an easy DMD-to-LDC transition.
•  » » 5 years ago, # ^ |   +10 I edited ldc's debug version flag, thanks :) I use stupid debug in usually(comment out all debug writeln before submit). I would use debug{} in future.
 » 5 years ago, # |   0 Auto comment: topic has been updated by yosupo (previous revision, new revision, compare).
 » 4 years ago, # |   +16 On SPOJ LDC2-1.1.0 is a little bit slower than DMD-2.072 (for several problems and same code I got TL for LDC2 and AC for DMD). It is very strange, because when I installed same versions of both compilers at home computer, sources compiled by LDC2 are executed about 1.5 times faster than compiled by DMD.
•  » » 4 years ago, # ^ |   +13 I guess this is caused by the compilier option, but I can't find compilier option of SPOJ
•  » » » 7 months ago, # ^ |   -10 I have implemented a D compiler configuration sanity checker program when investigating a rather abnormal GDC compiler performance on codechef. Running the same checker program via SPOJ customtest confirms that SPOJ also doesn't have any optimizations enabled for their LDC and GDC compilers even now: So no improvements in 3 years. I'm not a real SPOJ user myself, but maybe somebody could try to contact them? If no action is taken, then their compilers will remain misconfigured indefinitely.
 » 4 years ago, # |   +16 Recently, I start to use dlang in competitive programming Are you curious to try it or there are some advantages of Dlang over C/C++?
•  » » 4 years ago, # ^ |   +18 I've assembled some answer here.
•  » » » 4 years ago, # ^ |   +8 thank you Master Gassa for such detailed post cum answer.
 » 4 years ago, # |   0 or just google it