June 2010
Intermediate to advanced
456 pages
14h 48m
English
You know what’s coming first, so without further ado:
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 ...