Getting Started
So, when you have enough reasons to try D, let's get your hands dirty.
Contents
Your first program
For a beginner-friendly, step-by-step introduction on how to build your first D program see the hello world section of Ali Çehreli's online book Programming in D.
Choosing a compiler
As you probably already know, D is a compiled language, so you have to make your first choice: a compiler. There are several compilers to choose from.
They differ in:
- Installation procedure
- Ease of building from source
- License
- Performance
- Reliability
- Popularity
Whichever you will choose, you shouldn't have problems changing it. Options might differ but most code should be compatible with all of them. (If you find problems, please file an issue.)
Running D code like a script
After you have your compiler installed you'll want to do some coding.
For small projects it's handy to compile and run in a single step. Most (if not all) compiler packages, contain a tool named rdmd/gdmd/ldmd or similar. For instructional purposes we'll call it rdmd.
Just create your source file, e.g. main.d:
import std.stdio;
void main()
{
writeln("Hello, world without explicit compilations!");
}
and run the command line
rdmd main.d
If you properly installed the compiler you should see 'Hello, world without explicit compilations!' on the terminal. Isn't that simple?
For more information about this tool you might look at http://dlang.org/rdmd.html or your compiler documentation.
You can use exactly the same command for building programs that are made of separate modules. Just 'import' the other modules.
When your programs get larger, consider using a build system.
Choose your code editor
See IDEs and Text Editors to learn about D editing tools.
Using the D language for your domain
Do you want to develop a game, web application, desktop application, or use D to drive your robot? You can find more specialized information for different disciplines at Development with D.
Troubleshooting
Every complex software system might fail in its task. The same rule applies to DMD toolchain and maybe your application.
If you're having compilation/runtime problems and you have no idea why, don't worry. There are some tools that will help.
If your program doesn't compile and the error messages aren't enough, see Code Troubleshooting.
If your program compiled but doesn't do what you want, see Debuggers.
Beyond that, the D Community is very helpful.
And remember: If your problem has to do with the D toolchain or existing D projects, don't forget save some time for others by reporting it!
Searching with search engines
General considerations
Googling for "D" is useless in looking for D related web sites. But Googling for [D programming] or [D language] works well. Using dlang in combination with a search helps D in the TIOBE[1] index.
If you maintain a web page on D, please refer to it at least once per page as "D programming language" rather than just "D". This should help significantly with your page rank and findability for those interested in D.
Specific search engine
Let's say we want to search for the identifier indexOf using...
- Bing or Google: add site:dlang.org to your query. You'll get only the results which belong to the specified site:
indexOf site:dlang.org
Or add "dlang.org" to your query:
indexOf "dlang.org"
- Yahoo search: add domain:dlang.org to your search string. You'll get results from the specified domain:
indexOf domain:dlang.org