file no4
file no4
#drnsecintro#184>
~<#60299#>*Have students read the preface and conduct a pop quizz on the reading. Make sure they carry with them the program design recipe at all times and have it in front of them when they program. They will understand it more and more as they work through the book. We recommend that you cover numbers (section~#secbasics#186>), booleans (#seccondbooleans#187>), the shape of conditional expressions (beginning of #seccondprog2#188>), and symbols (#secsym#189>) as quickly as possible in a first pass. A student in a standard high school course should be able to understand this material in a week or less, that is, 5 sessions with one small homework per day. The goal is to get to the exercises~#exf2c#190>, #exconvert3#191>, #exguess1#192>, #excheckguess#193>, and #exguess2#194> [in that order]. These exercises show how modern programming works and why we <#195#>**don't*<#195#> wish to think about input and output concepts---yet. Programmers work out the essence, and then put together GUI interfaces with ``wizards''. The latter will be totally automated in the near future. It makes no sense to teach your students these skills; they may never need them, or if they do, the wizards will work in a different manner. The game exercise in section~#secsym#196> are generalized one more time in exercise~#exguess3#197>, where students learn to cope with lists. Then when the kids are bit more hooked, return to conditionals (#seccondprog2#198>), cover the two sections on design recipes again, and reinforce the section on composing programs. <#60299#>
We learn to compute at a young age. At first we just add and subtract
numbers.
One plus one equals two. Five minus two is three.

As we grow older we learn about additional mathematical operations, like
exponentiation and sine, but we also learn to describe rules of
computation.
Given a circle of radius <#202#>*r*<#202#>, its circumference is <#203#>*r*<#203#> times
two times <#204#>*pi*<#204#>. A minimum-wage laborer who works for <#205#>*N*<#205#> hours
earns <#206#>*N*<#206#> times 5.35 dollars.

The truth is, our teachers turn us into computers and program us to execute
simple computer programs.
So, the secret is out. Computer programs are just very fast students. They
can perform millions of additions while we might still be struggling with
the first one. But computer programs can do more than just manipulate
numbers. They can guide an airplane. They can play games. They can look
up a person's phone number. They can print the payroll checks for huge
corporations. In short, computers process all kinds of information.
People state information and instructions in English.
The temperature is #tex2html_wrap_inline72414#; convert this temperature into Fahrenheit. It
takes this car 35 seconds to accelerate from zero to 100 miles per hour;
determine how far the car gets in 20 seconds.

Computers, however, barely understand basic English and certainly can't
understand complex instructions expressed in English. Instead we must learn
to speak a computer language so that we can communicate information and
instructions.
A computer's language of instruction and information is a
<#60300#><#210#>PROGRAMMING LANGUAGE<#210#><#60300#>. Information expressed in a programming
language is called <#60301#><#211#>DATA<#211#><#60301#>. There are many flavors of data. <#212#>*Numbers*<#212#> are one class of data. <#213#>*Number series*<#213#> belong to
the class of <#60302#><#214#>COMPOUND DATA<#214#><#60302#>, because each series is made up of
other pieces of smaller pieces of data, namely, numbers. To contrast the
two kinds of data, we also call numbers <#60303#><#215#>ATOMIC DATA<#215#><#60303#>. Letters are
other examples of atomic data; family trees are compound data.
Data represents information, but the concrete interpretation is up to
us. For example, a number like 37.51 may represent a temperature, a time,
or a distance. A letter like ``A'' may denote a school grade, a quality
symbol for eggs, or a part of an address.
Like data, instructions, also called <#60304#><#216#>OPERATIONS<#216#><#60304#>, come in several
flavors. Each class of data comes with a set of <#60305#><#217#>PRIMITIVE OPERATIONS<#217#><#60305#>. For numbers, we naturally get <#60306#><#218#>`+`<#218#><#60306#>, <#60307#><#219#>`-`<#219#><#60307#>,
<#60308#><#220#>`*`<#220#><#60308#> and so on. Programmers compose primitive operations into
<#60309#><#221#>PROGRAMS<#221#><#60309#>. Thus, we may think of primitive operations as the
words of a foreign language and of programming as forming sentences in this
language.
Some programs are as small as essays. Others are like sets of
encyclopedias. Writing good essays and books requires careful planning,
and writing good programs does, too. Small or large, a good program cannot
be created by tinkering around. It must be carefully <#222#>*designed*<#222#>. Each
piece needs a lot of attention; composing programs into larger units must
follow a well-planned strategy. Designing programs properly must be
practiced from our very first day of programming.
In this book, we will learn to design computer programs, and we will learn
to understand how they function. Becoming and being a programmer is fun,
but it is not easy. The best part of being a programmer is watching our
``products'' grow and become successful. It is fun to observe a computer
program play a game. It is exciting to see a computer program help
someone. To get to this point, however, we must practice many skills. As we
will find out, programming languages are primitive; especially, their
grammar is restrictive. And unfortunately, computers are stupid. The
smallest grammatical mistake in a program is a fatal stumbling block for a
computer. Worse, once our program is in proper grammatical shape, it might
not perform the computations as intended.
Programming a computer requires patience and concentration. Only attention
to minute details will avoid frustrating grammatical mistakes. Only
rigorous planning and adherence to the plan will prevent serious logical
mistakes in our designs. But when we finally succeed with our designs, we
will have learned skills that are useful far beyond the realm of
programming.
Let's get started!