What's Wrong with this Program?

The output model for the ”Hello, world“ program and other traditional C programs is an antique piece of hardware known as the teletype. The teletype resembles a typewriter with a continuous roll of paper. In the not too distant past, programmers would sit at a teletype and type in commands that were echoed to the paper. The computer responded by printing its output on the paper.

The teletype metaphor was extended to the video display in the early days of computers. The video display became a ”glass teletype“ that simply scrolled when text reached the bottom of the screen.

How can the traditional ”Hello, world“ program display text without telling the operating system the particular output device on which the text is to appear? Because there is only one output device—the video display used as if it were a teletype. If the user wishes the output to go elsewhere, it must be redirected from the command line.

How can the program display text without telling the system where on the output device the text is to appear? Because the text always appears where the cursor happens to be, probably on the next line after you execute the program. Suppose you want to display ”Hello, world“ in the center of the screen. You'd have to use some device-dependent control codes to first position the cursor at the desired location.

Let's say you want to run several ”Hello, world“ programs at one time and see their output on the screen. What a mess! The copies of the program would interfere with each other. There is nothing in the teletype metaphor to separate output from several programs running concurrently.

It's also interesting that you see the ”Hello, world“ output even after the program terminates. Rather than properly cleaning up after itself, the program is leaving remnants of its existence on the video display.

The ”Hello, world“ program is so simple because it is designed for a simpler age and simpler computers and simpler output devices. It's not in the same ballpark as what we think of today as modern software, and it's not even playing the same game.