chapter 2 analytical engine: the orig- inal computerzshen/webfiles/notes/csdi1400/note2.pdfchapter 2...

29
Chapter 2 Analytical Engine: The Orig- inal Computer As we learned in the fourth grade science course, back in 1801, a French man, Joseph Marie Jacquard, invented a power loom that could weave textiles, which had been done for a long time by hand. More interestingly, this machine can weave tex- tiles with patterns such as brocade, damask, and matelasse by controlling the operation with punched wooden cards, held together in a long row by rope. 1

Upload: others

Post on 26-Apr-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Chapter 2

Analytical Engine: The Orig-inal Computer

As we learned in the fourth grade science course,

back in 1801, a French man, Joseph Marie

Jacquard, invented a power loom that could

weave textiles, which had been done for a long

time by hand.

More interestingly, this machine can weave tex-

tiles with patterns such as brocade, damask,

and matelasse by controlling the operation with

punched wooden cards, held together in a long

row by rope.

1

How do these cards work?

Each wooden card comes with punched holes,

each row of which corresponds to one row of

the design. In each position, if the needle

needs to go through, there is a hole; other-

wise, there is no hole.

Multiple rows of holes are punched on each

card and all the cards that compose the design

of the textile are hooked together in order.

2

What do we get?

With the control of such cards, needs go back

and forth, moving from left to the right, row

by row, and come up with something like the

following:

Although the punched card concept was based

on some even earlier invention by Basile Bou-

chon around 1725, “the Jacquard loom was

the first machine to use punch cards to con-

trol a sequence of operations”.

Let’s check out a little demo as how Jacquard’s

machine worked.

3

Why do we talk about a loom?

With Jacquard loom, if you want to switch

to a different pattern, you simply change the

punched cards.

By the same token, with a modern computer,

if you want it to run a different application,

you simply load it with a different program,

which used to keep on a deck of paper based

punched cards.

That is why Jacquard’s machine is considered

to be an important step towards the creation

of the modern computer as we know it.

4

How did the AE get started?

On June, 14, 1822, the English mathematician

Charles Babbage proposed a steam driven cal-

culating machine based on the decimal num-

ber system, which he called the “Difference

Engine”.

This machine would be able to compute tables

of numbers, such as logarithm tables. He ob-

tained government funding for this project due

to the importance of numeric tables in ocean

navigation.

Let’s check out Charles Babbage’s life and his

machines.

5

Who was the sponsor and why?

As we all know that, by promoting their com-

mercial and military navies, the British gov-

ernment had managed to become the earth’s

greatest empire in the late 16th and early 17th

centuries.

Around the time frame of Babbage’s proposal,

the British government was publishing a seven

volume set of navigation tables which came

with a companion volume of corrections, show-

ing that the set had over 1,000 numerical er-

rors, due to perhaps the complicated and bor-

ing nature of the calculation.

On the other hand, such calculations are all

governed by rules, thus “mechanical”. It was

hoped that Babbage’s machine could help to

eliminate errors in these types of tables.

6

It did not work out....

Unfortunately, construction of Babbage’s Dif-

ference Engine proved exceedingly difficult and

the project soon became the most expensive

government funded project ever. (More ex-

pensive than the “big dig”?)

Ten years later the device was still nowhere

near its completion, when the funding became

thin.

This project on the Difference Engine was never

completed....

7

...until now

Nevertheless, based on Babbage’s original plans,

the London Science Museum did construct a

working Difference Engine No. 2 during the pe-

riod of 1989 and 1991.

It later secured further funding to build another

machine. This machine, as shown below has

been on display, since May 10, 2008, in the

Computer History Museum in Mountain View,

CA.

Let’s have a look at how Babbage’s Difference

Engine No. 2 should have worked, as it sits in

the Computer History Museum.

8

AE came into the scene

Babbage did not give up. Instead, he proposed

the next machine, the famous Analytical En-

gine, which is an important step in the history

of computers.

It was first suggested in 1837, but Babbage

continued to work on the design until his death

in 1871.

Below shows a “renovated version” of the ma-

chine.

9

It goes again....

Because of financial, political, mechanical and

legal issues, the engine was never completely

built.

Some also believed that the technological lim-

itations of the time were a further obstacle to

the construction of the machine; others be-

lieved that the machine could have been built

successfully with the technology of the era if

funding and political support had been stronger.

Moreover, Charles Babbage was notoriously hard

to work with and alienated a great number of

people who had at first supported him, includ-

ing his engineer Joseph Clement. Thus, his

personality might also have played a part in

the failure of this project.

10

Analytic Engine and Computer

The design of the Analytical Engine was quite

similar to that of the general-purpose comput-

ers, completed about 100 years later in the

1940’s, in sense that it can execute many dif-

ferent programs to serve varying purposes.

This device, large as a house and powered by

six steam engines, would be general purpose

in nature because it would be programmable,

thanks to the punched card technology of Jacquard.

Moreover, Babbage made an important intel-

lectual leap regarding the punched cards.

11

Babbage’s idea

In the Jacquard loom, the presence, or the ab-

sence, of each hole in the card physically al-

lows a colored thread to pass or stop. Bab-

bage saw that the pattern of holes could be

used to represent either an abstract idea such

as a problem, i.e., instruction as how to solve

a problem, and/or the raw data required for

that problem’s solution.

Babbage actually realized that, at the very bot-

tom, a program can be represented the same

way as a piece of data.

This is exactly the same idea as we have been

using with modern computers, when “coding”

anything, including both programs and data,

with two digits, ‘0’ and ‘1’, i.e., doing math in

a binary system.

12

Here is more....

Furthermore, Babbage realized that punched

paper could be employed as a storage mech-

anism, holding computed numbers for future

reference.

Because of the connection to the Jacquard

loom, Babbage called the two main parts of his

Analytic Engine the ”Store” and the ”Mill”, as

both terms are used in the weaving industry.

The “Store” was where numbers were held and

the “Mill” was where they were ”woven” into

new results.

In a modern computer these same parts are

called the memory unit and the central pro-

cessing unit (CPU).

13

What could they do?

A “Store” can hold 1,000 numbers of 50 deci-

mal digits each, while an arithmetical unit (the

“Mill”) would be able to perform all four arith-

metic operations, plus comparisons and op-

tionally square roots.

The input (programs and data) was to be pro-

vided to the machine via punched cards, a

method being used at the time to direct me-

chanical looms such as the Jacquard loom.

For output, the machine would have a printer,

a curve plotter (drawing pictures?) and a bell

(ringing for attention?).

The machine would also be able to punch num-

bers onto cards to be read in later, using the

ordinary base-10 fixed-point arithmetic.

Did I tell you the truth? Let’s check it out.

14

What else?

The Analytic Engine also had a key function

that distinguishes itself from calculators: the

conditional statement.

When we use a calculator to crunch on num-

bers, we can only carry out a sequence of cal-

culations.

We often follow such a pattern in our life: Get

up; Have breakfast; Have a class; Have the

next class; Have lunch; Have another class;

Have dinner; Watch TV; Go to bed;

You just start at the beginning, do one thing

at a time, until the end.

15

Conditional structure

On the other hand, a conditional structure

allows a program to achieve different results

each time it is run, depending on certain con-

ditions.

We also make such a judgment in our lives:

If it feels cold, put on a jacket, otherwise, a

T-shirt.

It can be represented as follows:

if (if feels cold)

then put on a jacket

else just wear a T-shirt

16

A real example

A modern traffic light at an intersection be-

tween a busy street and a less busier street will

leave the green light on the busy street until a

car approaches on the less busier street.

This type of street lights is controlled by a

computer program that can sense the approach

of cars on the less busier street.

Whether the light changes from green to red

is not fixed in the program but rather depends

on the real-time traffic situation.

17

The code

A control structure for the above case can look

like the following:

If a car approaches on the less busier street

and the light for the busy street is green

for at least a minute

Then

Switch the green light in favor of the less

busier street.

The conditional statement also allows a pro-

gram to react to the results of its own calcu-

lations.

Another example would be the program that

the IRS uses to detect tax fraud. This program

first computes a person’s tax liability and then

decides whether to alert the IRS agents based

upon how that person’s tax payments compare

to his obligations, thus whether sends him an

auditing notice.

18

The other stuff

Another control structure that we now use, be-

sides the conditional and the sequential struc-

tures, is the loop structure, i.e., keep on doing

something until and unless a condition flips.

For example, assume that you are at least 21

years old,

While not drunken

Keep on drinking

Question: Compare the above philosophy with

the following, and tell which one is more so-

cially responsible?

Keep on drinking

Until drunken

It turns out that every program is just a com-

bination of the above three structures.

19

An example

We can use the following program to find outthe average mileage of a few cars.

1. Repeat step 2 to step 10 until response is no

2. Get values for gallons, start and end

3. Set the value of distance to (end − start)

4. Set the value of average to (distance/gallons)

5. Print the value of average

6. If average > 25.0 Then

7. Print the massage “You are getting good gas mileage.”

8. Else Print the massage “You are not getting a goodgas mileage.”

9. Print the massage “Do you want to repeat?”

10. Get a value for response from the user

11. Stop

20

The first programmer

Another important development was that Bab-

bage befriended Ada Byron, the daughter of

the famous poet Lord Byron.

(Ada would later become the Countess Lady

Lovelace by marriage)

21

Ada’s achievement

Though Ada was only 19, she was fascinated

by Babbage’s ideas and, through letters and

meetings with Babbage, she learned enough

about the design of the Analytic Engine to

begin writing programs for the yet completed

computer.

In fact, Ada wrote a series of “Notes”, with

which she provided detailed sequences of in-

structions that she had prepared for the Ana-

lytic Engine, programs indeed.

22

An important piece

A program these days is essentially a collection

of functions that call each other, starting with

the main function.

Among other accomplishments, Ada invented

the “subroutine” idea, where a group of often

used instructions is organized into a unit which

can be run with even changing inputs. She was

also the first to recognize the importance of

the loop structure, which we just mentioned.

Thus, Ada earned her spot in history as the

first computer programmer. Later on, a pro-

gramming language was named after Ada. For

more information on this programming pioneer,

check out the attached link.

Let’s watch a little video on Lady Lovelace.

23

What happened to AE?

A committee eventually recommended against

constructing the Analytical Engine in 1878.

Late in his life, Babbage sought ways to build

a simplified version of the machine, and assem-

bled a small part before his death in 1871.

In 1910, Babbage’s son Henry P. Babbage re-

ported that part of the “Mill”, i.e., the pro-

cessor, and the printing part, had been con-

structed to calculate a (faulty) list of multiples

of π(= 3.1415925 . . .).

But, this is only a small part of the whole en-

gine: it was not programmable and had no

storage.

24

Nothing was really done.

Henry also proposed building a demonstration

version of the full engine, with a smaller stor-

age capacity: “perhaps for a first machine ten

[columns] would do, with fifteen wheels in each.”

Such a version could manipulate 20 numbers of

25 digits each, and what it could be told to do

with those numbers would still be impressive.

“It is only a question of cards and time,” wrote

Henry Babbage in 1888, “... and there is no

reason why [twenty thousand] cards should not

be used if necessary, in an Analytical Engine for

the purposes of the mathematician.”

Unfortunately, nothing followed through.

25

What might have happened?

If Babbages Analytical Engine was completed,

made of iron and brass, and powered with steam

engine, would have the equivalent of 1.7 kilo-

bytes of memory, and it could do four arith-

metic operations, together with left and right

shift, comparison and jump.

It would take a long time to get things done:

a single addition would take 13,000 times as

long as on a Z80, an 8 bit microprocessor that

people used in the mid-1970’s.

Let’s watch a little video to wrap this up.

26

Another attempt

According to the December, 2010 issue of Com-

munication of ACM, John Graham-Cumming,

a British programmer and author now wants

to implement Babbage’s Analytical Engine.

More specifically, John plans to create a 3D

virtual model of Babbage’s machine, works out

all the bugs, and then builds it. As part of the

project, John also plans to digitize Babbage’s

papers and make them available on line.

The project is estimated to take up to five

years and might cost 1.6 million US dollars.

John has started a web page at

http:\\www.plan28.org to ask for money, and

he plans to start the project once he has 10,000

pledges. About 4,000 eventually signed up,

and the project failed.

27

Student activities

Do some research on Babbage and his Differ-

ence Engine, Analytical Engine, and the work

done by Ada, pick some topic among the fol-

lowing list, write up a “one page and single

space” essay and we will talk about them in a

group setting, followed by a class presentation:

1. Compare and contrast the Analytical En-

gine with a modern computer.

2. Give a fuller analysis as why the British

government needed Babbage’s machine to help

its work.

3. What did Ada actually do? Talk about

some of her actual instructions, used in the

“first program”, and compare them with con-

temporary programming.

28

4. Read the original report made by the British

Association for the Advancement of Science in

1878, available in the included site, and sum-

marize the main reasons why the Committee

decided against the construction of the Analyt-

ical Engine. Do they make sense? Why? You

should also discuss the validity of these rea-

sons in the context of the actual development

in this front afterwards.

5. Do some research about early attempts

of building a practical computer between the

Babbage time and the 1945, where the first

computer, ENIAC, came up. Explore the pos-

sible reasons why it is in the 1940’s when the

first fully functional computer was born. You

might consider this issue in terms of techni-

cal capability, economic resource, intellectual

readiness, the level of need, etc..

29