25% developed

A Beginner's Guide to D

From Wikibooks, open books for an open world
Jump to navigation Jump to search

For Experienced Programmers[edit | edit source]

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[edit | edit source]

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 [[/Chapter/Section Title/|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[edit | edit source]

  1. Before We Begin...
    1. Short Introduction to D
    2. D Compiler
    3. Editors Supporting D
  2. The Basics
    1. The Structure of D
    2. Start at the Beginning
    3. Introduction to Modules
    4. Types and Math [input of a few different types, up to dynamic arrays]
    5. Basic Output [using std.stdio.writef/writefln]
    6. Basic Input [using std.cstream.din]
  3. Conditions and Loops
    1. The Concepts of Conditionals and Loops
    2. Simple Branching
    3. Simple Iteration
    4. Simple Looping (The while and do-while loops)
    5. Complex Iteration (The for Loop)
    6. Conditions and Loops/Switch Statement (The Switch conditional)
  4. Functions and Simple Arguments [somewhere in this chapter, segfaults and other failures should be briefly introduced but simply refer to a later chapter]
    1. The Concept of Functions [NOT in the Functional Programming sense]
    2. Simple Functions
    3. Recursion
    4. Passing Basic Types
    5. Passing Arrays
    6. Assertion and Contracts
  5. Basic Classes and Object Orientation
    1. The Concept of Classes
    2. Simple Classes [an extension to the input programs above that has a "person" class with char[] name, int age, etc.]
    3. Methods
    4. Data Hiding
      1. Public vs Private
      2. Accessor Methods and Properties
  6. Exceptions and Handling [This chapter should also mention segmentation faults]
    1. The Concept of Exceptions
    2. Throwing Exceptions
    3. Simple Catching
    4. The finally Clause
  7. Advanced Arrays
    1. Dynamic Arrays, Concatenation and COW
    2. Static Arrays
    3. Associative Arrays
  8. Modules
    1. Modules and the Filesystem
    2. Making your Own Modules
    3. Importing Modules
      1. Public vs private vs static imports
      2. Namespace and Conflicts
  9. Advanced Object Orientation
    1. Friendly Classes
    2. Class Inheritance
      1. Simple Inheritance
      2. Interfaces
    3. Operator Overloading
    4. x. --- TO BE COMPLETED ---
  10. Advanced Functions and Arguments [This chapter should perhaps be switched with the last one]
    1. Review of Passing
    2. Passing Classes
    3. Passing by-val vs. by-ref: in, out, inout
    4. x. Function Pointers and Delegates?
    5. x. --- TO BE COMPLETED ---
  11. Templates and Generic Programming
    1. Template Classes
    2. Template Functions
    3. Mixins
    4. Advanced Templates
  12. Miscellaneous and Advanced Features
    1. Functions
      1. Lazy Evaluation
    2. Object Orientation
      1. Structs and Packing
      2. Unions
    3. Enumerations
  13. 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
  • Signals and slots
  • Tuples
  • 'scope' for object variables
  • Sockets
  • Threads