This course is called "Principles of Computing and Programming". What do these terms mean?

Let's calculate your share of the cost of a pizza if a pizza has 8 slices and costs $12. What do we need to know? How many slices you ate:

- if you ate 1 slice, you owe (12 / 8) * 1 = 1.50
- if you ate 2 slices, you owe (12 / 8) * 2 = 3
- if you ate 12 slices, you owe (12 / 8) * 12 = 18

Let's calculate the cost of a pizza if it has a base price of $9 and each topping costs $1.50. What do we need to know? How many toppings:

- with 1 topping, the cost is 9 + (1 * 1.5) = 10.50
- with 2 toppings, the cost is 9 + (2 * 1.5) = 12
- with 5 toppings, the cost is 9 + (5 * 1.5) = 16.50

From physics, we know how to compute the weight of an abject on another planet:

plnt-wgt (ew prm prr) = ew * (prm / (prr * prr))

where ew is the object's weight on earth, prm it the planet's mass relative to that of earth and prr is the planet's radius relative to that of earth. Jupiter's mass is 318 times that of earth and its radius is 11 times that of earth.

- a 100 newton object weighs 100 * (312 / (* 11 11)) = 257
- a 400 newton object weighs 400 * (312 / (* 11 11)) = 1028

Once we know how to calculate something, we'd like to make a computer do it (the computer is less error-prone and faster; besides, we get bored performing repetitive calculations). Computers require rules that explain how to perform computations. What are the rules for our earlier examples?

If you ate s slices, you owe (12 / 8) * s.

If a pizza has t toppings, it costs 9 + (t * 1.5).

If an object weighs w newtons on earth, it weighs w * (312 / (* 11 11)) on Jupiter.

We need to express rules and computations in a notation that the computer can understand. This notation is called a programming language. COMP 210 uses a language called Scheme. Here are several examples of how to translate computations into Scheme:

Computation/Rule Scheme ------------------------------------------------ 5 5 1.20 * 1 (* 1.20 1) 6 * pi * (3 * 3) (* 6 (* pi (* 3 3))) (4 + 7) * 2 (* 2 (+ 4 7)) sqrt((a * a) + (b * b)) (sqrt (+ (* a a) (* b b))) owe(s) = (12 / 8) * s (define (owe s) (* (/ 12 8) s)) cost(t) = 9 + (t * 1.5) (define (cost t) (+ 9 (* t 1.5))) plnt-wgt (ew prm prr) = (define (plnt-wgt ew prm prr) ew * (prm / (prr * prr)) (* ew (/ prm (* prr prr))))

Programming is the process of expressing computations such that a computer can perform them.

What happens when we ask DrScheme to compute (owe 5)? Imagine that there is a little person inside the machine who is extremely fast at doing computations. He performs the following steps:

(owe 5) = (* (/ 12 8) 5) = (* 3/2 5) = 15/2

This gives you an introduction to programming. That leaves computing. What is computing?

Computing consists of two activities: representing information and developing techniques to process information. Consider three examples:

- Researchers model the structure of molecules to develop hew drugs using computers. The information to represent is the structure of the molecules. The techniques to process molecules are functions that combine molecules to form new drugs.
- Genealogical databases capture family trees. You may use this database to trace your ancestors. If that database contains medical information, doctors might use it to study how a disease evolves within one family. The information is the data about individual people, their relationships, and their medical histories. Searching and detecting patterns in medical histories are techniques for processing that information.
- Your bank uses software to manage its accounts and to run its ATMs. That software needs to be secure, so that it won't give your money to someone else by mistake. The information in this case is the software (program) itself. Analyzing that software for security flaws is the processing technique.

Computing is interesting when the information that we process is complex. Today's examples used only numbers. Numbers by themselves aren't interesting. We'll start working with new forms of information later this week.

What's the relationship between programming and computing? Programming is the tool through which we teach a computer how to compute for us. Thus, computing needs programming. However, programming also needs computing because programming without thinking about computing is error-prone and futile. Thus, there's a deep symbiosis between computing and programming. We'll study this connection in COMP 210.