Skip to content
Hello, D
step 1/5

Reading — step 1 of 5

Learn

~1 min readBasics

D was designed in 2001 by Walter Bright as a successor to C++. Native code performance, garbage collection (optional), expressive type system, ranges instead of iterators.

import std.stdio;

void main() {
    writeln("Hello, D!");
}
  • import std.stdio; brings in I/O. The standard library is namespaced as std.*.
  • writeln(x) writes x + newline. write(x) writes without newline.
  • void main() — works exactly like C/C++.
  • Statements end with ;. C-style braces.

D is statically typed with strong type inference (auto x = 5; infers int). Dynamic-feeling syntax — looks like Python, runs like C.

Reading stdin: readln() returns a string with trailing newline; use chomp from std.string to strip:

import std.string : chomp;
string line = readln().chomp;

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…