Why do we use Hello World? – the history behind it

Why do we use Hello World? – the history behind it

Originally posted on dev.

Hello World!
Oh wait… Hello everyone!

I got bored today and did some intense research on the history of Hello World!. My mission (of finding out why us programmers use “Hello World!” instead of something like a simple “Hi”, “Test” or random key spam) succeeded and I felt like sharing this truly mindblowing history with the DEV community.


~ Where it all started

The first time “Hello World” was exposed to the public wasn’t actually through IT, but through the radio. Back in the 1950’s it was used as a catchphrase by William Williams.
The genius that brought Hello World! to the programming space appears to be the one and only Brian Kernighan.
It is unclear whether it was first used in the B Language or in BCPL (released 1967). It certainly was mentioned and had an appearance in both languages, however Brian didn’t publicly mention it for quite some time after the BCPL release.
He first publicly referenced these legendary 2 words in his work The Programming Language B for the publishers of the language, bell-labs. While the language itself was published all the way back in 1969, his Introduction to it was written 3 years later, in 1972.

Ever since then Brian seemed to enjoy including Hello World! in his books, for example in another work for bell-labs titled “Programming in C” (1974).

But through these 2 publications Hello World! didn’t gain any real traction.
That was until Kernighan decided to put it in yet another book (this time not for bell-labs) which he wrote with the developer of C (Dennis Ritchie). It bears the simple title “The C Programming Language” and was released back in 1978.


~ Why?

So here I will cover 3 different things, firstly, why is Hello World! even used, and second, why the hell it is “Hello World!” and not something else, and last but not least, why did it get so popular?.

Why do we use Hello World as our first program?

Everyone used it at least once. But why? Well, to put it simply, to check if everything works. If you run your program and see an output, you can be certain that your compiler and all environments have been installed successfully and correctly. While this was more necessary back in the day, it became a tradition for newbies to write Hello World. This might also be because it is commonly used to teach the most basic syntax of a language!

Why exactly “Hello World”

The question about why exactly us developers use “Hello World” instead of a simple “Test”, “Hi” or some random key spam, was hard to research. But I managed to find a few things.

So the use of Hello World actually dates back to the book on the B language. Back then it was used to display the functionality of variables. Since “hi” was too simple there was a need for an option that required more character constants. So basically it was used to explain the basics of B since in B you can only store up to 4 (ASCII) characters in one constant/variable.
It was used due to it’s functionality!

Why is it so popular?

But why did it get so damn popular, and especially when? Well to understand why it is so popular, we should take a look at the old alternatives.
Here we have this intimitating line: MY HUMAN UNDERSTANDS ME. This glorious line was brought to the masses by Bob Albrecht through his book My Computer Likes Me When I Speak in BASIC which was published in the same year as the work that exposed Hello World to the public for the first time (1972). The mentioned line wasn’t very widely spread, however, it was at least something that could have been used as a first program by the ancient developers.

So at this point it may appear obvious why it gained so much popularity. It’s simplicity and also functionality allowed “Hello World” to be way more popular then the previously mentioned version. While having the same effect, Hello World managed to show the “student” what they are supposed to do in a more effective and easy way.
However, it only gained traction with the release of Brian and Dennis’ book on the C language in 1978. Due to Cs’ rising popularity more and more people got to know the line and implemented it in their code while learning. After a while, it became a tradition that is still being used to this day in many different languages to get familar with the most basic syntax of the language:
B:

main( ) {
    extern a, b, c;
    putchar(a); putchar(b); putchar(c); putchar('!*n');
}

a 'hell';
b 'o, w';
c 'orld';

BCPL:

get "streams.d"
external
[
Ws
]

let Main() be
[
Ws("Hello World!*N")
]

C:

#include <stdio.h>
int main() {
   printf("Hello World!");
   return 0;
}

Python:

print("Hello World!")

Java:

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!"); 
    }
}

Go:

package main

import "fmt"
func main() {
    fmt.Println("Hello World!")
}

Brainfuck:

>++++++++[<+++++++++>-]<.>++++[<+++++++>-]<+.+++++++..+++.>>++++++[<+++++++>-]<+
+.------------.>++++++[<+++++++++>-]<+.<.+++.------.--------.>>>++++[<++++++++>-
]<+.

…and many many more!


~ Outro

Hello World is an amazing tradition since many years, decades even. While it first used to make an example more complex, it is nowadays being used to not just test code but also to teach new programmers the most basic syntax of a language.
Also, it’s quite lucky that Brian got to write the book on C. Otherwise we would probably still be stuck on getting screamed at when executing our “Hello World” program.

No need to thank me for this useless information, though any feedback would be highly appreciated! Maybe I will find some other useless topic to talk about in the future!
With that being said, have a great rest of your day 🙂

~ Sources:

https://en.wikipedia.org/wiki/%22Hello,_World!%22_program
https://www.thesoftwareguild.com/blog/the-history-of-hello-world/
https://www.bell-labs.com/usr/dmr/www/bintro.html
https://en.wikipedia.org/wiki/B_(programming_language)

 

Source: dev