DLang Notes and Examples
← prev | next →     Top-level ToC     /quickstart.html     (printable version)

1 Implementations

There are three main implemenations of D:

Official reference compiler. Lightning fast compilation.
GCC-based (uses DMD front-end).
LLVM-based (uses DMD front-end)

As DMD is now (as of 2017-04-07) free software (boost license), I use it unless I have good reason to use one of the other implementations.

2 Install DMD

On Debian, for the latest version, you can manually download D and install the dmd .deb file:

dpkg -i dmd_2.076.1-0_amd64.deb

(Searching around with apt-cache, I wasn’t able to find dmd in the standard repository, though did find ldc and gdc.)

3 Editor/IDE Support

Lots of editors support D. Geany in nice.

On Emacs do M-x package-list-packages and install d-mode. After that, to get 4-space indents, add this to your ~/.emacs file:

(add-hook 'd-mode-hook
          (lambda ()
            (setq c-basic-offset 4)
            (setq tab-width 4)))

4 Running

4.1 Scripts

For simple script-like programs, create a foo.d file:

#!/usr/bin/env rdmd

import std.stdio;

void main() {

then chmod +x foo.d, and ./foo.d to run it.

rdmd is having dmd compile that first, and then is running it. Oh yes, dmd is fast.

4.2 Typical Projects

For more typical projects, see Typical Project Structure.