5.4 Hello World Review
We’ve seen three different approaches to coding a simple program. Each approach shared similar characteristics.
- We started with a failing test that provided a specification for our program.
- We wrote a program to make the test pass (and thereby ensure our program fulfilled the requirement).
- We reran our tests to make sure we had met the requirement.
You may also notice how similar the programs are to one another. They all amount to a single ‘print’ statement. Although programming languages vary considerably in detail, you will often find many common features. When learning, try to identify the core ideas as these often translate between languages. ‘print’ is a good example, many languages share the idea of printing to the computers display and this is often achieved using a ‘print’ statement of some form.
Does this mean all computer languages have a ‘print’? No. In Haskell, for example, we might write putStrLn "Hello World!"
but the result is similar (display a message on the screen). Sometimes we have to be more explicit about where to print the message. In Java we
might say System.out.print("Hello World!")
to print to the screen3.
3Technically we are printing to the console.