Where “Hello, World” came from

Your first program probably greeted the world before it did anything useful.
It did not sort a list, save a file or calculate a mortgage. It printed two words. You looked at the output, checked it against the tutorial, and had the first small piece of evidence that the machine would do what you asked.
“Hello, World” is so familiar that its history gets compressed into a single sentence: it came from Kernighan and Ritchie’s book about C.
The book helped make it famous. But the greeting was already there before the book — and before its familiar C version. Stranger still, one early surviving version was not the tutorial’s first working program at all.
Before C, there was B
Brian Kernighan’s A Tutorial Introduction to the Language B
contains the greeting in section 7, which introduces external variables. Earlier
sections already include a program that adds three numbers and another that
prints hi!.
The greeting is split across three character constants:
'hell'
'o, w'
'orld'
These are not modern strings. The tutorial’s B implementation can pack up to
four characters into a machine word. Three external variables hold those
chunks; successive calls to putchar print them, followed by an exclamation
mark and a newline. The result is hello, world!.
So the example demonstrates a particular feature of B, rather than just choosing the smallest possible program. What became a universal opening ritual appears here partway through a lesson about how data lives outside a function.
That is a better origin story than “someone needed a first line of code.” The greeting had a job before it became a tradition.
C moved the greeting to the front
Kernighan’s early Programming in C — A Tutorial does put the greeting near the beginning. Section 2, “A Simple C Program,” contains this historical example:
main( ) {
printf("hello, world");
}
It is notably not the version many people remember. There is no #include,
no explicit return type, no exclamation mark and no newline in that opening
example. Later, the tutorial introduces \n and explains how it puts the
greeting on a line of its own.
This is a historical specimen, not a template to copy into a modern C project. The language and its conventions were still developing. Dennis Ritchie’s history of C places its formative period in 1969–1973, with especially intense development in 1972. B was its immediate ancestor.
The teaching idea survived the changing syntax: start with something whose success you can see.
The book was the amplifier
Kernighan and Dennis Ritchie published The C Programming Language in 1978; Kernighan’s own bibliography records both that edition and the second edition of 1988.
Ritchie describes the 1978 book as the first widely available description of C. On his historical archive page, he also explains that the earlier tutorial grew into much of the book, while the reference manual became Appendix A.
The book did not invent a greeting from scratch. It carried an existing teaching pattern into a far more visible form. Princeton’s account of Kernighan’s contribution likewise distinguishes his B manual from the later C book that popularised it.
That distinction is worth keeping. The remembered milestone and the earliest surviving example are not necessarily the same thing.
Why print something so trivial?
Here is our reading of the ritual: “Hello, World” is less a test of your algorithm than a test of the path between you and the machine.
Can you create a source file? Are you running the file you just edited? Can the compiler or interpreter find what it needs? Does execution reach your code? Do you know where the output appears?
Those questions sound elementary until one of them has the wrong answer. Someone can understand loops perfectly and still lose an afternoon to a missing executable, a wrong directory or an editor saving the wrong file.
A deliberately boring program removes most of the other suspects. There is no business logic to debug yet. If the greeting appears, you have a small working baseline to change.
This is not just a retrospective justification. Princeton’s archived Hello World assignment explicitly frames the exercise around becoming familiar with the mechanics of using the computer and preparing and submitting a program.
The tiny result is doing a larger logistical job.
A convention that still earns its place
The official Go getting-started tutorial still uses the greeting. It takes the reader through creating a directory, initialising a module, writing a program and running it before moving on to an external dependency.
The surrounding machinery is different from B’s packed character constants. The useful checkpoint is recognisably the same.
Of course, a greeting cannot prove that an application is correct, secure or ready to deploy. It cannot even prove that it runs anywhere except the environment you just used. There is a reason developers also recognise “it works on my machine”.
But that does not make the first checkpoint worthless. It makes it the first checkpoint, not the last.
The enduring appeal is modest: before asking a new environment to do something complicated, ask it to answer. Two familiar words turn an opaque setup into a conversation you can continue.
Hello, world. Now change something.

