"Hello, World!": The Origin of the Universal First Program
Zusammenfassung
The phrase “Hello, World!” as a programming example first appeared in a 1972 Bell Labs internal memorandum by Brian Kernighan — a tutorial introduction to the language B, the predecessor of C. It appeared in a slightly different form in Kernighan and Ritchie’s 1978 book The C Programming Language, which standardized the phrase and the practice of using it as the canonical first program. Today, “Hello, World!” is written in every new programming language as a demonstration that the language compiles, the toolchain works, and the output system is functioning. No one planned for this to become a universal convention; it simply propagated.
The Bell Labs Tutorial
Brian Kernighan wrote “A Tutorial Introduction to the Language B” as an internal Bell Labs memorandum in 1972. B was the language Ken Thompson had designed as a simplified version of BCPL for use on the PDP-7 and PDP-11; it preceded C directly. The tutorial needed an example program that was simple enough to not distract from the language itself while demonstrating something real. Kernighan chose a program that printed text.
The original text in the 1972 B tutorial was:
main() {
extrn a, b, c;
putchar(a); putchar(b); putchar(c); putchar('!*n');
}
a 'hell';
b 'o, w';
c 'orld';The output was “hello, world” in lowercase without an exclamation mark. B’s string handling required the message to be stored as separate global variables in 4-character chunks — the syntax reflects B’s 36-bit word architecture and its lack of a native string type.
The tutorial circulated within Bell Labs and influenced the people writing C. When Kernighan returned to the example for the 1978 K&R book, C had strings, and the canonical example became the version that has been reproduced billions of times since:
main()
{
printf("hello, world\n");
}The K&R Book and Its Influence
The C Programming Language by Brian Kernighan and Dennis Ritchie, published in 1978 by Prentice-Hall, was the defining programming book of its era. It was short (228 pages), precise, and written by the people who had designed C while using it to write Unix. Its first program was “hello, world” — lowercase, comma after “hello,” lowercase “w” in “world.” The exclamation mark was added by convention in later adaptations.
The book was used to teach C to an entire generation of programmers. When those programmers began writing their own language tutorials and documentation, they reached for the same example. When programming languages began providing official “Getting Started” documentation, the convention was established enough that departing from it required conscious decision.
The universality is almost total: Python, Java, Ruby, Go, Rust, Haskell, Swift, Kotlin, JavaScript — every major language’s documentation begins with “Hello, World!” The phrase appears in documentation for languages running on microcontrollers, in quantum computing SDKs, in GPU shader languages, and in every programming tutorial on the internet.
What “Hello, World!” Actually Tests
The first program in a new environment is almost never written to demonstrate the language’s power. It is written to verify that the entire toolchain works: that the compiler or interpreter is installed correctly, that the build system can find the source file, that the linker can find the standard libraries, and that the output mechanism — standard output, a display, a serial port — is connected and functional. “Hello, World!” tests all of this in the minimum possible program.
The choice of a human-readable message rather than a number or an empty program is deliberate: a human reading the output can immediately verify correctness without consulting a manual. The message is also grammatically complete — a greeting, implying the machine has acknowledged your presence and responded.
The convention has become so universal that it functions as a shibboleth: a new programming language that does not have a “Hello, World!” example in its documentation is not considered ready for general use. The phrase Kernighan chose for pedagogical economy in 1972 became the global convention for how humans first speak to a new machine.
📚 Sources
- Kernighan, Brian W.: “A Tutorial Introduction to the Language B” — Bell Laboratories internal memorandum, 1972 (reproduced at cm.bell-labs.com)
- Kernighan, Brian W. & Ritchie, Dennis M.: The C Programming Language (1978), Prentice-Hall
- Kernighan, Brian W.: “In Memoriam: Dennis M. Ritchie” — IEEE Annals of the History of Computing, Vol. 34, No. 2 (2012)