Chapter 1. “D”iving In

You know what’s coming first, so without further ado:

Click here to view code image

import std.stdio;void main() {   writeln("Hello, world!");}

Depending on what other languages you know, you might have a feeling of déjà vu, a mild appreciation for simplicity, or perhaps a slight disappointment that D didn’t go the scripting languages’ route of allowing top-level statements. (Top-level statements invite global variables, which quickly turn into a liability as the program grows; D does offer ways of executing code outside main, just in a more structured manner.) If you’re a stickler for precision, you’ll be relieved to hear that void main is equivalent to an int main that returns “success” (code zero) to the operating ...

Get The D Programming Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.