How to Write Programs

  • Share
  • Read Later

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?

  1. Previous Page
  2. 1
  3. 2