Hello world
A “Hello, world” program is usually a simple computer program that outputs a message similar to “Hello, world”. The text may be printed out or displayed on a screen (often a console). A small piece of code in most general-purpose programming languages, this program is used to illustrate a language’s basic syntax. Such a program is often the first written by a student of a new programming language,11 James A. Langbridge, Professional Embedded ARM Development (John Wiley & Sons, 2013). but it can also be used as a sanity check to ensure that the computer software intended to compile or run source code is correctly installed, and that its operator understands how to use it.
History

While several small test programs have existed since the development of programmable computers, the tradition of using the phrase “Hello, world” as a test message was influenced by an example program in the 1978 book The C Programming Language,22
Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language, 1st ed. (Prentice Hall, 1978), p. 6.
with likely earlier use in BCPL. The example program from the book prints "hello, world", and was inherited from a 1974 Bell Laboratories internal memorandum by Brian Kernighan, Programming in C: A Tutorial:33
Brian Kernighan, Programming in C: A Tutorial (Bell Labs, 1974).
main( ) {
printf("hello, world");
}
In the above example, the main( ) function defines where the program should start executing. The function body consists of a single statement, a call to the printf() function, which stands for “print formatted”; it outputs to the console whatever is passed to it as the parameter, in this case the string "hello, world".
The C-language version was preceded by Kernighan’s own 1972 A Tutorial Introduction to the Language B,44 S. C. Johnson and B. W. Kernighan, The Programming Language B (Bell Labs). where the first known version of the program is found in an example used to illustrate external variables:
main( ) {
extrn a, b, c;
putchar(a); putchar(b); putchar(c); putchar('!*n');
}
a 'hell';
b 'o, w';
c 'orld';
The program above prints hello, world! on the terminal, including a newline character. The phrase is divided into multiple variables because in B, a character constant is limited to four ASCII characters. The previous example in the tutorial printed hi! on the terminal, and the phrase hello, world! was introduced as a slightly longer greeting that required several character constants for its expression.
The Jargon File reports that “hello, world!” instead originated in 1967 with the language BCPL.55 “BCPL”, Jargon File. Outside computing, use of the exact phrase began over a decade prior; it was the catchphrase of New York radio disc jockey William B. Williams beginning in the 1950s.66 “William B. Williams, Radio Personality, Dies”, The New York Times, 4 August 1986.
Variations
“Hello, world” programs vary in complexity between different languages. In some languages, particularly scripting languages, the “Hello, world” program can be written as one statement, while in others (more so many low-level languages) many more statements can be required. For example, in Python, to print the string Hello, world followed by a newline, one only needs to write print("Hello, world"). In contrast, the equivalent code in C++77
“C++ Programming/Examples/Hello world”, Wikibooks.
requires the import of the C++ standard library, the declaration of an entry point (main function), and a call to print a line of text to the standard output stream.
Adapted from “Hello, world” on Wikipedia, CC BY-SA 4.0. Photo by Brian Kernighan, CC BY-SA 3.0.
Footnotes
-
James A. Langbridge, Professional Embedded ARM Development (John Wiley & Sons, 2013). ↩
-
Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language, 1st ed. (Prentice Hall, 1978), p. 6. ↩
-
Brian Kernighan, Programming in C: A Tutorial (Bell Labs, 1974). ↩
-
S. C. Johnson and B. W. Kernighan, The Programming Language B (Bell Labs). ↩
-
“William B. Williams, Radio Personality, Dies”, The New York Times, 4 August 1986. ↩
-
“C++ Programming/Examples/Hello world”, Wikibooks. ↩