Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

d
basics

What is the D programming language?

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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:

svg viewer
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.

svg viewer
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!");
}
A basic program in D

RELATED TAGS

d
basics
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.