Lecture 1 : Warming Up

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:

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:

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.

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:

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.