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