The classical example of a program is Hello World. In Python this would be
It prints two words to the terminal. Not very inspiring.
If we wanted an actual simple example of computation, a better example might be to implement the Toffoli on three binary inputs
if a and b:
c = not c
This is the basic unit of computation. Any program can be compiled into repeated calls of this. It’s pretty much the only syntax you need in a programming language. Rather than bother with high level concepts like
+, you could do it all with the endless Toffolis.
Of course, so sane person would want to. But doing all of computation in just two lines is a pretty nice first program.
So why do we just do the boring printing of an input that is Hello World? I would say that there is probably three main reasons.
- History. It is what we found our forebears doing.
- Relatability. The program is perfectly understandable in itself. Unlike the Toffoli, you don’t need a lecture in Boolean algebra to understand why you should care.
- Debugging. After a successful Hello World, we have a window into our programs. We know how to see if our program is doing what it should. It allows the program and programmer to talk to each other, and that conversation is where everything happens.
Which is the most important? Are there other reasons? These are questions I want to answer. Quantum computers are coming, and many programmers are already asking us what the quantum Hello World is. We need to find the right answer.