Introduction to D

1.1 What is D?

A general-purpose, statically typed, compiled systems programming language. Walter Bright created it (first release 2001), and Andrei Alexandrescu co-designed D2 (2007+).

Goal: the power of C++ with the productivity of Python/Java/C#. It's fast to compile, fast to run, and expressive.

It's multi-paradigm: imperative, object-oriented, functional, generic, metaprogramming, and contract programming.

1.2 Key Features

Compiles to machine code. Performance is comparable to C/C++.

DMD compiles large codebases in seconds Garbage collection (optional)

GC by default. Manual memory, RAII, @nogc, and BetterC are also available.

@safe subset, bounds checking, DIP1000 scope checks A powerful lazy-iteration abstraction (better than iterators)

Templates, CTFE, static if, mixins, compile-time reflection

Uniform Function Call Syntax: x.f(y) ≡ f(x, y) in/out conditions and invariant blocks Built-in unittests and docs unittest blocks, Ddoc Immutability and purity

immutable, const, pure are checked by the compiler Message passing, shared, fibers, parallelism

Direct C ABI, C++ ABI, Objective-C, plus ImportC (compiles C code directly)

1.3 Compilers

Digital Mars (reference) Fastest compilation, latest features, development

Best optimization, many targets (ARM, WASM, iOS/Android) Part of GCC, wide platform support

1.4 Who Uses D?

Symmetry Investments, Weka.io (storage), eBay (tsv-utils), Mercedes-Benz R&D, Netflix (vectorflow), Funkwerk, Auburn Sounds (audio plugins), Ahrefs, and games and indie projects.

1.5 D vs Other Languages

GC + manual + RAII Very fast (DMD) Excellent (CTFE, mixins) Reflection (runtime) @safe opt-in Strong by default