What is the D programming language?

D (also known as Dlang) is a multi-paradigm system programming language created by Walter Bright at Digital Mars and released in 2001. D combines a wide range of powerful programming concepts from the lowest levels to the highest. It emphasizes memory safety, program correctness, and pragmatism.

svg viewer

Some key benefits of D are outlined below.

Multi-paradigm language

D comes with multiple paradigms:

Multiple programming paradigms of D language
Multiple programming paradigms of D language
  • Concurrent programming: has language constructs for concurrency, these may involve multi-threading, etc.

  • Functional programming: uses the evaluation of mathematical functions and is capable of avoiding state and mutable data.

  • Meta programming: writing programs that write or manipulate other programs (or themselves) as their data.

  • Generic programming: uses algorithms written in terms of to-be-specified-later types that are then instantiated as needed-for- specific-types provided as parameters.

  • Imperative programming: explicit statements that change a program state.

  • Object-oriented programming: uses data structures, that consist of data fields and methods, together with their interactions (objects) to design programs.

Memory safety and management

D does not require explicit memory management. It has a garbage collector that scans the memory at unspecified times, determines the objects that cannot possibly be reached by the program anymore, destroys them, and reclaims their memory locations.

Memory management by using the garbage collector
Memory management by using the garbage collector

Productivity

D helps to increase productivity by providing features such as:

  • Modules
  • Templates
  • Associative arrays
  • Documentation

Performance and reliability

D is a highly reliable, high-performance language; thus, it allows the programmer to write and compile codes faster and without any bugs. It achieves this by:

  • Lightweight aggregates
  • Inline assembler
  • Contracts
  • Unit testing
  • Debug attributes and statements
  • Exception handling
  • Synchronization

Basic example

The following example shows how to print “Hello World” in D.

import std.stdio;
void main() {
writeln("Hello World!");
}