Workspace

D

systems programming native tools and C-family productivity

Definition first

What D means

D is a programming language for writing exact instructions, often used for systems programming native tools and C-family productivity. Start with one mental model: input goes through steps and becomes output.

Minimum run factsFile main.dRun dmd main.d && ./mainHabit Use strong types and keep memory choices visible
Program

An ordered set of instructions. It reads input, follows rules, and produces output.

Value and variable

A value is data. A variable is the name you use to hold and reuse that data.

Function

A named piece of work. It takes input, does one job, and can return a result.

Runtime

D compiler is the place that actually runs code from main.d.

First readable code

Program output

entry point output syntax writeln
writeln(42);
Output 42

Language lineage

D family tree

See where D comes from, which languages feel close, and what to learn next.

roots
C++CJava
currentDC++ successor family
familyC++ successor family
best used for

systems code with high level features and compiled performance

Zero base path

1Read one rule2Predict output3Type from memory4Run checklist5Repeat with one change

Question bank

Search before practice

Pick a stage or search across the open programming bank. Jump straight to the matching drill.

18 matching questions
Q 1ChoiceStage 1 definitions

D practice 1

D question 1. Choose the statement that matches printing a value.

Q 2ChoiceStage 1 definitions

D practice 2

D question 2. Choose the statement that matches naming a value.

Q 3ChoiceStage 1 definitions

D practice 3

D question 3. Choose the statement that matches reusable function.

Q 4ChoiceStage 1 definitions

D practice 4

D question 4. Choose the statement that matches basic collection.

Q 5ChoiceStage 1 definitions

D practice 5

D question 5. Choose the statement that matches printing a value.

Q 6ChoiceStage 1 definitions

D practice 6

D question 6. Choose the statement that matches naming a value.

Q 7ChoiceStage 1 definitions

D practice 7

D question 7. Choose the statement that matches reusable function.

Q 8ChoiceStage 1 definitions

D practice 8

D question 8. Choose the statement that matches basic collection.

Q 9ChoiceStage 1 definitions

D practice 9

D question 9. Choose the statement that matches printing a value.

Q 10ChoiceStage 1 definitions

D practice 10

D question 10. Choose the statement that matches naming a value.

Q 11ChoiceStage 1 definitions

D practice 11

D question 11. Choose the statement that matches reusable function.

Q 12ChoiceStage 1 definitions

D practice 12

D question 12. Choose the statement that matches basic collection.

Q 13ChoiceStage 1 definitions

D practice 13

D question 13. Choose the statement that matches printing a value.

Q 14ChoiceStage 1 definitions

D practice 14

D question 14. Choose the statement that matches naming a value.

Q 15ChoiceStage 1 definitions

D practice 15

D question 15. Choose the statement that matches reusable function.

Q 16ChoiceStage 1 definitions

D practice 16

D question 16. Choose the statement that matches basic collection.

Q 17ChoiceStage 1 definitions

D practice 17

D question 17. Choose the statement that matches printing a value.

Q 18ChoiceStage 1 definitions

D practice 18

D question 18. Choose the statement that matches naming a value.

Multiple choice

D practice 1

Q 1Choicenew

D question 1. Choose the statement that matches printing a value.

writeln(42);

Reference

Patterns for main.d

D compilerdmd main.d && ./main
Recall from memoryRead a small point then write it back without looking
Trace the codeWrite variable values line by line before you run the answer
Type it yourselfCopy less type more and fix one small error at a time

entry point output syntax writeln

Program output

writeln(42);
  • Run the smallest file first
  • Print one known value
  • Check the output before adding more code

variables assignment types int

Values and names

int total = 42;
writeln(total);
  • Give values readable names
  • Keep one idea per line while learning
  • Trace the value before changing it

function collection Array

Functions and collections

int add(int a, int b) {
  return a + b;
}

int[] scores = [40, 2];
writeln(scores.length);
  • Keep functions small
  • Return useful values
  • Use the common collection before reaching for frameworks