A Beginner's Guide to D

For Experienced Programmers
D is very similar to languages like C++ and Java. Therefore, if you have experience with those languages, you can probably pick up D by simply reading the /D Transition Guide/.

Status of this Text
This book will be a guide to people starting to program using the D programming language. It is intended for a range of audiences, from people new to programming to the seasoned programmer. The book has been arranged so that you can follow the suggested chapter order, which will lead you through the concepts such that you can use them before finishing the book. Alternatively, you can select the chapters as you see fit, skipping over some things that you might already be familiar with.

This book does not include a comprehensive introduction to programming as there are many sources for that already, though it does have a refresher on the topic.

The content of this book is based on the use of the Phobos standard library which comes with the DigitalMars dmd compiler.

Before contributing, please read the /Style Guide/.


 * The Table of Contents is almost done, so this book is now open for content. If you want to write a page, first read the /Style Guide/, then choose a page, replace the text in the list below with a link to the name you want like so:

/Chapter/ or Section Title (The /'s are important), and put some note on the page to say you're going to handle it (to try to minimize duplication).

Table of Contents

 * 1) /Before We Begin.../
 * 2) Short Introduction to D
 * 3) D Compiler
 * 4) Editors Supporting D
 * 5) /The Basics/
 * 6) The Structure of D
 * 7) Start at the Beginning
 * 8) Introduction to Modules
 * 9) Types and Math [input of a few different types, up to dynamic arrays]
 * 10) Basic Output [using std.stdio.writef/writefln]
 * 11) Basic Input [using std.cstream.din]
 * 12) /Conditions and Loops/
 * 13) The Concepts of Conditionals and Loops
 * 14) Simple Branching
 * 15) Simple Iteration
 * 16) Simple Looping (The while and do-while loops)
 * 17) Complex Iteration (The for Loop)
 * 18) /Conditions and Loops/Switch Statement/ (The Switch conditional)
 * 19) Functions and Simple Arguments [somewhere in this chapter, segfaults and other failures should be briefly introduced but simply refer to a later chapter]
 * 20) The Concept of Functions [NOT in the Functional Programming sense]
 * 21) Simple Functions
 * 22) Recursion
 * 23) Passing Basic Types
 * 24) Passing Arrays
 * 25) Assertion and Contracts
 * 26) Basic Classes and Object Orientation
 * 27) The Concept of Classes
 * 28) Simple Classes [an extension to the input programs above that has a "person" class with char[] name, int age, etc.]
 * 29) Methods
 * 30) Data Hiding
 * 31) Public vs Private
 * 32) Accessor Methods and Properties
 * 33) Exceptions and Handling [This chapter should also mention segmentation faults]
 * 34) The Concept of Exceptions
 * 35) Throwing Exceptions
 * 36) Simple Catching
 * 37) The finally Clause
 * 38) Advanced Arrays
 * 39) Dynamic Arrays, Concatenation and COW
 * 40) Static Arrays
 * 41) Associative Arrays
 * 42) Modules
 * 43) Modules and the Filesystem
 * 44) Making your Own Modules
 * 45) Importing Modules
 * 46) Public vs private vs static imports
 * 47) Namespace and Conflicts
 * 48) Advanced Object Orientation
 * 49) Friendly Classes
 * 50) Class Inheritance
 * 51) Simple Inheritance
 * 52) Interfaces
 * 53) Operator Overloading
 * 54) x. --- TO BE COMPLETED ---
 * 55) Advanced Functions and Arguments [This chapter should perhaps be switched with the last one]
 * 56) Review of Passing
 * 57) Passing Classes
 * 58) Passing by-val vs. by-ref: in, out, inout
 * 59) x. Function Pointers and Delegates?
 * 60) x. --- TO BE COMPLETED ---
 * 61) /Templates and Generic Programming/
 * 62) Template Classes
 * 63) Template Functions
 * 64) Mixins
 * 65) Advanced Templates
 * 66) Miscellaneous and Advanced Features
 * 67) Functions
 * 68) Lazy Evaluation
 * 69) Object Orientation
 * 70) Structs and Packing
 * 71) Unions
 * 72) Enumerations
 * 73) TO BE CONTINUED

Things to be added (in no particular order; feel free to add these yourself):
 * Preprocessor-like functionality:
 * Pragmas
 * Conditional Compilation
 * Mixins
 * Probably in the (to-be-described) templates section
 * Function Pointers and Delegates
 * If the Advanced Functions chapter comes after Advanced OO, this fits there.
 * Garbage Collection
 * Not sure where to put this
 * Scoped statements
 * Not sure where to put this
 * Type-casting
 * Needs to be in multiple places
 * Array literals
 * Probably should be in /The Basics/Types and Math/
 * Signals and slots
 * Tuples
 * 'scope' for object variables
 * Sockets
 * Threads