D Tutorial /
Starting With D
To start developing in D there are several things to cover. These include choosing a version of D and run-time library based on your needs and desired libraries. A good starting point for learning the language is to start with D1.x and with Phobos (the default install from Digital Mars). As you learn the language you will be better positioned to choose Tango or D2.x. The specification is where you will find the most details on the language and decent explanations on features if you are familiar with C like languages.
|
Selecting
Version of D
There are currently two versions of D. The stable Run-time Library
If you have chosen to work with D1.x there is a choice of run-time libraries the standard library, Phobos, and Tango. These libraries are not compatible aside from using Installing a Compiler
Once a version and run-time library has been chosen, the choice of compiler becomes straight forward. Read the Compilers page for more information and installation instructions.
Useful Libraries/Tools
Now that your are set up with an environment to compile simple D programs. You can take a look at the libraries and development tools, but here are a few quick suggestions:
Writing "Hello World"
D source code files are typically plain text files such as those that can be edited by Notepad in Windows. If you would like a fancier editor, there are several options listed at EditorSupport. But Notepad is enough.
So create this text file using your favorite editor (let's call it as nothing.d):
|
You might be wondering what it all means, so I'll break it down:
- This is the main function of the program (hence the name "main").
- The keyword "void" indicates that the function doesn't return a type.
- The parentheses () indicate a parameter list. In this example, there are no parameters.
- The braces {} indicate a block of statements. In this simplistic example, there aren't any statements.
For how to compile the program, read the documentation on your compiler of choice.
Now to get some output from the program. Since this will depend on if you are using Phobos or Tango, here are two examples:
|
|
Related
- Tutorials
- Learning D as a first language
- Learning D as a second language
- Language Specification
- Seeking help using D
- Language Development
- Development with D