• U.S.

How to Write Programs

5 minute read

Hardware is not difficult to understand. It is nuts and bolts and microchips. But what is software? Perhaps the easiest way to think of it is in terms of a simple analogy: hardware is to software as a television set is to the shows that appear on it. Computer programs, rather like those aired on TV, are a man-made effort to turn lifeless hardware into something one might want to spend some time with.

Programs, like television scripts, are “written”—not in English, but in English-like commands that vary from machine to machine. BASIC, for example, is a “language” most desktop computers are wired to understand.

In the past, computer owners had to write their own software. Today thousands of prewritten programs are on the market, ranging from games to accountants’ tools. Running these software packages, as opposed to writing them, is no more difficult than playing a record or a videotape. Just find the appropriate disc, put it in a disc drive and push a button. In a matter of seconds the computer is programmed and set to do the job at hand—from balancing the books to finding misspelled words to playing a video game.

Making the programs, however, involves grueling and painstaking work, most of it done by a software engineer, also known as a programmer. Just what is it that a programmer does and how does he do it?

The first step is to decide what you want the computer to do—play blackjack, manipulate text, juggle figures? Once the task is clearly defined, the programmer lays out a step-by-step procedure for executing that task. Think of these procedures as roughly akin to cookbook recipes. The recipe for playing blackjack, for example, might go something like this: “Get a deck of cards. Shuffle the cards. Deal two cards to each player. Ask the first player if he wants another card. Did the face value of that third card put his total over 21? If not, ask if he wants another card …”

Once the task is set and the recipe spelled out, the programmer sits down at a computer and translates each step into commands that the machine can understand. A typical command might say: PRINT “DO YOU WANT ANOTHER CARD?”

The computer, interpreting commands one word at a time, recognizes the word PRINT and the quotation marks that follow it. It has been wired to gather up messages that appear between quotation marks and translate them, character by character, into sequences of numbers. These numbers, in turn, are translated into a corresponding sequence of electrical signals. These signals are sent to an electron “gun” housed in the vacuum tube behind the computer’s video screen. This gun, following the sequence of signals, fires bursts of electrons at the back side of the screen. The electrons strike bits of phosphor that coat the screen and energize them, lighting up a pattern of dots. These dots form the shape of alphabetic characters, spelling out the message: DO YOU WANT ANOTHER CARD?

Thankfully, the programmer does not have to worry about every electron and phosphor dot. He has enough on his hands typing his commands into the computer and testing them to see if they do what he meant them to do. Even a program for playing blackjack can quickly grow to be hundreds of lines long, each line densely packed with convoluted commands and alphanumerical characters. If there is even one character out of place in those hundreds of lines, chances are the program will not work properly. These software “bugs,” as programming mishaps are called, can take weeks to find. One bug in an AT&T program knocked out all long-distance telephone service to Greece in 1979. It was months before Ma Bell’s programmers pinned down the problem.

When the programmer has thoroughly tested and corrected his work he stores it on a magnetic tape,or disc, much as someone might use a tape recorder to store a noteworthy speech. A particularly useful or entertaining computer program might be accepted by one of the growing number of software publishers. They will copy the program onto blank discs and send them to computer stores around the country.

When a user slips his brand-new blackjack program into a disc drive and turns on his computer, the drive starts spinning the disc at a rate of hundreds of revolutions per minute. As the disc spins, a record-playback head moves across its surface, picking up the original programmer’s typed instructions and loading them into the computer’s memory. When the disc stops spinning—presto!—an exact replica of the program will be imprinted on the machine’s temporary memory, all debugged and ready to deal the cards. Or, depending on the disc, proofread the term paper, balance the books or tell you to sell the hogs.

More Must-Reads from TIME

Contact us at letters@time.com