A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Hello World in D page! Here, you'll find the source code for this program as well as a description of how the program works.
import std.stdio;
void main()
{
writeln("Hello, World!");
}
Hello World in D was written by:
This article was written by:
If you see anything you'd like to change or update, please consider contributing.
At any rate, let's get to the implementation of Hello World in D.
At this point, you may be questioning whether or not D is even a new language. After all, this Hello World implementation looks a lot like C/C++.
Well, then it should come as no surprise the solution is pretty much
the same. We have basically three main parts: the import
statement,
the main
function, and the print function.
Just like C/C++, the first thing we do is import our standard IO
library. In this case, D references std.stdio
as opposed to stdio.h
in C.
Up next, we have our usual main
function. At this point in the series,
we're pretty use to this syntax.
Finally, we have our typical print function. In this case, we call
writeln
and pass a string to it.
If we wanted to run our code snippet from above, we can leverage an online D compiler.
Alternatively, we can download our own D compiler from the official website. Then, we'll want to get a copy of Hello World in D. After that, we can simply run the following:
rdmd hello-world.d
And, that's it! The string "Hello, World!" should appear in the console.