Lecture0.ppt

46
COSC1557: Introduction to Computing Haibin Zhu, PhD. AssistProfessor Department of Computer Science Nipissing University •(C) 2002

description

 

Transcript of Lecture0.ppt

Page 1: Lecture0.ppt

COSC1557: Introduction to Computing

•Haibin Zhu, PhD.•AssistProfessor•Department of Computer Science•Nipissing University•(C) 2002

Page 2: Lecture0.ppt

InstructorInstructor

• Haibin Zhu, Ph. D.Haibin Zhu, Ph. D.

• Assistant Professor, Department of CS and Assistant Professor, Department of CS and Math, Nipissing UniversityMath, Nipissing University

• Room: A124A Ext.: 4434Room: A124A Ext.: 4434

• Email: Email: [email protected]@nipissingu.ca

• URL: URL: http://www.nipissingu.ca/faculty/haibinzhttp://www.nipissingu.ca/faculty/haibinz

• Office Hour: Mon.–Fri. 2:30pm-4:30pm, Office Hour: Mon.–Fri. 2:30pm-4:30pm, and by appointmentand by appointment

Page 3: Lecture0.ppt

Course DescriptionCourse Description

• Nature and uses of the computer-, Nature and uses of the computer-, algorithms-, number systems, algorithms-, number systems, information representation; and information representation; and organization, with an overview of organization, with an overview of computer hardware and software, computer hardware and software, computing systems and major computing systems and major applications. Ethical and societal issues applications. Ethical and societal issues arc discussed. An introduction to high-arc discussed. An introduction to high-level languages with an emphasis on level languages with an emphasis on writing programs in C++. writing programs in C++.

Page 4: Lecture0.ppt

Textbook and referencesTextbook and references• Textbook:Textbook: Joel Adams and Larry Nyhoff, C++: Joel Adams and Larry Nyhoff, C++:

An Introduction to Computing, 3/e. Prentice An Introduction to Computing, 3/e. Prentice Hall, © 2003 ISBN: 0-13-091426-6Hall, © 2003 ISBN: 0-13-091426-6

• Lecture Notes on Lecture Notes on http://cs.calvin.edu/books/c++/intro/3e/PPSlides/http://cs.calvin.edu/books/c++/intro/3e/PPSlides/

• Student Supplements: CD-Lab Manual (ISBN: Student Supplements: CD-Lab Manual (ISBN: 013080648X)013080648X)

• Some Lab: Some Lab: http://cs.calvin.edu/books/c++/intro/3e/HandsOnChttp://cs.calvin.edu/books/c++/intro/3e/HandsOnC++/++/

Page 5: Lecture0.ppt

[email protected]

Beginning SnapshotsBeginning Snapshots

Chapter 0Chapter 0

Page 6: Lecture0.ppt

ObjectivesObjectives

• Give an overview of computer scienceGive an overview of computer science– Show its breadthShow its breadth

• Provide context for computer science Provide context for computer science conceptsconcepts– Events from the pastEvents from the past

• Describe basic components, organization Describe basic components, organization of a computerof a computer

Page 7: Lecture0.ppt

Areas of Computer Areas of Computer ScienceScience

• Algorithms and Data Algorithms and Data StructuresStructures

• ArchitectureArchitecture

• Artificial Intelligence Artificial Intelligence and Roboticsand Robotics

• Database and Database and Information RetrievalInformation Retrieval

• Human-Computer Human-Computer CommunicationCommunication

• Numerical and Numerical and Symbolic ComputationSymbolic Computation

• Operating SystemsOperating Systems

• Programming Programming LanguagesLanguages

• Software Methodology Software Methodology and Engineeringand Engineering

• Social and Social and Professional ContextProfessional Context

Page 8: Lecture0.ppt

Important Concepts in Computer Important Concepts in Computer HistoryHistory

• The mechanism of arithmeticThe mechanism of arithmetic

• The stored programThe stored program

• The graphical user interfaceThe graphical user interface

• The computer networkThe computer network

Page 9: Lecture0.ppt

First-Generation First-Generation ComputersComputers

• Vacuum tube computersVacuum tube computers 1945-1945-19561956– ENIACENIAC 1943-1943-

19461946

– John Von Neumann'sJohn Von Neumann's"First Draft of a Report on"First Draft of a Report onthe EDVAC"the EDVAC" 19451945

– First bug in a computerFirst bug in a computer 19451945

– UNIVACUNIVAC 19511951

Page 10: Lecture0.ppt

Second Generation Second Generation ComputersComputers

• Used transistorsUsed transistors 1956-19631956-1963

• FORTRANFORTRAN 19571957

• IBM 7090IBM 7090 19581958

LISPLISP

• COBOLCOBOL 19601960

ALGOL 60ALGOL 60

Page 11: Lecture0.ppt

Third-Generation Third-Generation ComputersComputers• Chips and Integrated Chips and Integrated

CircuitsCircuits 1964-19711964-1971

• The IBM System/360The IBM System/360 19641964

• The PDP-8The PDP-8 19651965

• Douglas Englebart: Douglas Englebart: the mouse, Two-D display, the mouse, Two-D display, editing, hypermedia,editing, hypermedia, 19681968

PascalPascal

• Ken Thompson: UNIXKen Thompson: UNIX 19691969

ARPANET – The beginning of the InternetARPANET – The beginning of the Internet

Page 12: Lecture0.ppt

Fourth-Generation Fourth-Generation ComputersComputers

• Intel 4004 ChipIntel 4004 Chip 19711971

• Dennis Richie: CDennis Richie: C 19731973

• EthernetEthernet

• Court rules Atanasoff was legal inventor of Court rules Atanasoff was legal inventor of first electronic digital computerfirst electronic digital computer

• Altair, BASIC, Apple 1Altair, BASIC, Apple 1 19741974

• Apple II, Cray 1, Apple Corp.Apple II, Cray 1, Apple Corp.Microsoft Corp.Microsoft Corp. 19761976

• IBM PCIBM PC 19811981

Page 13: Lecture0.ppt

Fourth-Generation Fourth-Generation ComputersComputers• Bjarne Stroustrup: C++Bjarne Stroustrup: C++ 19831983

Novell announces NetwareNovell announces NetwareTCP/IPTCP/IP

• MacintoshMacintosh 19841984

• WindowsWindows 19851985

• Intel 386 ChipIntel 386 Chip 19861986

• Tim Berners—Lee: WWWTim Berners—Lee: WWW 19911991

• LinuxLinux 19921992

Page 14: Lecture0.ppt

Fourth-Generation Fourth-Generation ComputersComputers• Pentium chips, Power PC chipPentium chips, Power PC chip 19931993

MOSAIC, Apple NewtonMOSAIC, Apple Newton

• Netscape Navigator 1.0, Yahoo!Netscape Navigator 1.0, Yahoo! 19941994Palm computingPalm computing

• James Gosling: JAVAJames Gosling: JAVA 19951995Windows 95, Internet Explorer,Windows 95, Internet Explorer,Internet goes commercialInternet goes commercial

• Windows 98, Apple's IMACWindows 98, Apple's IMAC 19981998Microsoft's court caseMicrosoft's court case

Page 15: Lecture0.ppt

Fourth-Generation Fourth-Generation ComputersComputers

• Y2K Problem, Powermac G4Y2K Problem, Powermac G4 19991999

• Windows 2000Windows 2000 200020001 GHZ processors1 GHZ processors

• Mac OS XMac OS X 20012001Windows XPWindows XP

• Quantum ComputerQuantum Computer 20022002

Page 16: Lecture0.ppt

Graphical User InterfaceGraphical User Interface

• Command line interface required precise Command line interface required precise and cryptic commandsand cryptic commands

• Xerox PARK had developed GUI prototype Xerox PARK had developed GUI prototype in 1972in 1972– Steve Jobs saw it several years later and Steve Jobs saw it several years later and

used new hardware capabilities to implementused new hardware capabilities to implement

• GUI makes computer easy to useGUI makes computer easy to use

Page 17: Lecture0.ppt

NetworkNetwork

• Defn: Two or more computers Defn: Two or more computers connect to exchange resourcesconnect to exchange resources– Processing powerProcessing power

– StorageStorage

– Access to a printerAccess to a printer

– Software resourcesSoftware resources

– MessagesMessages

Page 18: Lecture0.ppt

NetworkNetwork

• Time sharing in early 1960sTime sharing in early 1960s– Users communicate with host computerUsers communicate with host computer

• ARPANET connected research center ARPANET connected research center computers in 1969computers in 1969– Eventually developed into InternetEventually developed into Internet

• Local Area Network hardware and Local Area Network hardware and operating systems developed late 1970soperating systems developed late 1970s

• ISPs now affordable, widely available for ISPs now affordable, widely available for even home computerseven home computers

Page 19: Lecture0.ppt

Calvin College •[email protected]

Computer OrganizationComputer Organization

Hardware and Software

Page 20: Lecture0.ppt

Computing SystemsComputing Systems

Computers have two kinds of Computers have two kinds of components:components:

• HardwareHardware, consisting of its physical , consisting of its physical devices (CPU, memory, bus, storage devices (CPU, memory, bus, storage devices, ...)devices, ...)

• SoftwareSoftware, consisting of the programs it , consisting of the programs it has (Operating system, applications, has (Operating system, applications, utilities, ...)utilities, ...)

Page 21: Lecture0.ppt

Hardware: CPUHardware: CPU

Central Processing Unit (CPU):Central Processing Unit (CPU):– the “brain” of the machine(?)the “brain” of the machine(?)

– location of circuitry that performs location of circuitry that performs arithmetic and logical ML statementsarithmetic and logical ML statements

– measurement: speed (roughly) in measurement: speed (roughly) in megahertz (millions of clock-ticks per megahertz (millions of clock-ticks per second)second)

– examples: Intel Pentium(PI, PII, PIII, P4), examples: Intel Pentium(PI, PII, PIII, P4), AMD K6, Motorola PowerPC, Sun SPARC, AMD K6, Motorola PowerPC, Sun SPARC,

Page 22: Lecture0.ppt

Hardware: RAMHardware: RAM

Random Access Memory (RAM)Random Access Memory (RAM)

– ““main” memory, which is fast, but main” memory, which is fast, but volatilevolatile......

– analogous to a person’s short-term memory.analogous to a person’s short-term memory.

– many tiny “on-off” switches: for conveniencemany tiny “on-off” switches: for convenience• ““on” is represented by 1, “off” by 0.on” is represented by 1, “off” by 0.

– each switch is called a each switch is called a bbinary diginary digitit, or , or bitbit..• 8 bits is called a 8 bits is called a bytebyte..

• 221010 bytes =1024 bytes is called a bytes =1024 bytes is called a kilobytekilobyte (1K) (1K)

• 222020 bytes is called a bytes is called a megabytemegabyte (1M). (1M).

Page 23: Lecture0.ppt

Hardware (Disk)Hardware (Disk)

Secondary Memory (Disk):Secondary Memory (Disk):– Stable storage using magnetic or optical Stable storage using magnetic or optical

media.media.

– Analogous to a person’s long-term memory.Analogous to a person’s long-term memory.

– Slower to access than RAM.Slower to access than RAM.

– Examples: Examples: • floppy disk (measured in kilobytes)floppy disk (measured in kilobytes)

• hard disk (measured in gigabytes (2hard disk (measured in gigabytes (23030 bytes)) bytes))

• CD-ROM (measured in megabytes), ...CD-ROM (measured in megabytes), ...

Page 24: Lecture0.ppt

Hardware: the BusHardware: the Bus

The Bus:The Bus:– Connects CPU to other hardware devices.Connects CPU to other hardware devices.

– Analogous to a person’s spinal cord.Analogous to a person’s spinal cord.

– Speed measured in megahertz (like the Speed measured in megahertz (like the CPU), but typically much slower than the CPU), but typically much slower than the CPU...CPU...

– The bottleneck in most of today’s PCs. The bottleneck in most of today’s PCs.

Page 25: Lecture0.ppt

Hardware: CacheHardware: Cache

While accessing RAM is faster than While accessing RAM is faster than accessing secondary memory, it is still accessing secondary memory, it is still quite slow, relative to the rate at which quite slow, relative to the rate at which the CPU runs.the CPU runs.

To circumvent this problem, most systems To circumvent this problem, most systems add a fast add a fast cache memorycache memory to the CPU, to to the CPU, to store recently used instructions and data.store recently used instructions and data.

(Assumption: Since such instructions/data (Assumption: Since such instructions/data were needed recently, they will be needed were needed recently, they will be needed again in the near future.)again in the near future.)

Page 26: Lecture0.ppt

Hardware: SummaryHardware: Summary

Putting the pieces together:Putting the pieces together:

CPU

Bus

MainMemory

SecondaryMemorycache

Programs are stored (long-term) in secondary memory, Programs are stored (long-term) in secondary memory, and loaded into main memory to run, from which the and loaded into main memory to run, from which the CPU retrieves and executes their statements.CPU retrieves and executes their statements.

Page 27: Lecture0.ppt

Software: OSSoftware: OS

The The operating systemoperating system (OS) is loaded from (OS) is loaded from secondary memory into main memory when secondary memory into main memory when the computer is turned on, and remains in the computer is turned on, and remains in memory until the computer is turned off.memory until the computer is turned off.

RAM DiskCPUCache

Bus

OS

Page 28: Lecture0.ppt

Software: OSSoftware: OS

The OS acts as the “manager” of the system, The OS acts as the “manager” of the system, making sure that each hardware device making sure that each hardware device interacts smoothly with the others.interacts smoothly with the others.

It also provides the interface by which the It also provides the interface by which the user interacts with the computer, and user interacts with the computer, and awaits user input if no application is awaits user input if no application is running.running.

Examples: Windows 2000, Windows XP, Examples: Windows 2000, Windows XP, Windows-NT, UNIX, Linux, Solaris, Windows-NT, UNIX, Linux, Solaris, MacOS, ... MacOS, ...

Page 29: Lecture0.ppt

Software: ApplicationsSoftware: Applications

Applications are non-OS programs that Applications are non-OS programs that perform some useful task, including perform some useful task, including word processors, spreadsheets, word processors, spreadsheets, databases, web browsers, C++ databases, web browsers, C++ compilers, ...compilers, ...

Example C++ compilers/environments: Example C++ compilers/environments: – CodeWarrior (MacOS, Win95, WinNT, Solaris) CodeWarrior (MacOS, Win95, WinNT, Solaris)

– GNU C++ (UNIX, Linux)GNU C++ (UNIX, Linux)

– Turbo/Borland C++ (Win95, WinNT)Turbo/Borland C++ (Win95, WinNT)

– Visual C++ (Win95, WinNT)Visual C++ (Win95, WinNT)

Page 30: Lecture0.ppt

Software: User ProgramsSoftware: User Programs

Programs that are neither OS programs Programs that are neither OS programs nor applications are called user nor applications are called user programs.programs.

User programs are what you’ll be writing User programs are what you’ll be writing in this course.in this course.

Page 31: Lecture0.ppt

Putting it all togetherPutting it all together

Programs and applications that are not running Programs and applications that are not running are stored on disk.are stored on disk.

RAM DiskCPUCache

Bus

OS App

Page 32: Lecture0.ppt

Putting it all togetherPutting it all together

When you launch a program, the OS controls the When you launch a program, the OS controls the CPU and loads the program from disk to RAM.CPU and loads the program from disk to RAM.

RAM DiskCPUCache

Bus

OS AppA

ppOS

Page 33: Lecture0.ppt

Putting it all togetherPutting it all together

The OS then relinquishes the CPU to the The OS then relinquishes the CPU to the program, which begins to run.program, which begins to run.

RAM DiskCPUCache

Bus

OS AppA

ppApp

Page 34: Lecture0.ppt

The Fetch-Execute CycleThe Fetch-Execute Cycle

As the program runs, it repeatedly fetches the As the program runs, it repeatedly fetches the next instruction (from memory/cache), executes next instruction (from memory/cache), executes it, and stores any results back to memory.it, and stores any results back to memory.

RAM DiskCPUCache

Bus

OS AppAppA

pp

That’s all a computer does: fetch-execute-That’s all a computer does: fetch-execute-store, store, millions of times each secondmillions of times each second!!

Page 35: Lecture0.ppt

ProgrammingProgramming

Page 36: Lecture0.ppt

What is Programming?What is Programming?

A sequence of statements that instruct a A sequence of statements that instruct a computer in how to solve a problem is computer in how to solve a problem is called a called a programprogram..

The act of designing, writing and The act of designing, writing and maintaining a program is called maintaining a program is called programmingprogramming..

People who write programs are called People who write programs are called programmersprogrammers..

Page 37: Lecture0.ppt

What kinds of statementsWhat kinds of statementsdo computers do computers understand?understand?

A computer only understands A computer only understands machine language statements.machine language statements.

A machine language statement is a A machine language statement is a sequence of ones and zeros that sequence of ones and zeros that cause the computer to perform a cause the computer to perform a particular action, such as add, particular action, such as add, subtract, multiply, ...subtract, multiply, ...

Page 38: Lecture0.ppt

Machine Language (ML)Machine Language (ML)

ML statements are stored in a computer’s ML statements are stored in a computer’s memory, which is a sequence of memory, which is a sequence of switches. switches.

For convenience of representation, For convenience of representation, an “on” switch is represented by 1, an “on” switch is represented by 1, and an “off” switch is represented by 0.and an “off” switch is represented by 0.

ML thus appears to be binary (base-2):ML thus appears to be binary (base-2):

00101110101101010010111010110101

Page 39: Lecture0.ppt

Early ComputersEarly Computers

... required a programmer to write in ... required a programmer to write in ML...ML...– Easy to make mistakes!Easy to make mistakes!

– Such mistakes are hard to find!Such mistakes are hard to find!

– Not Not portableportable -- only runs on one kind of -- only runs on one kind of machine!machine!

Programming was very difficult! Programming was very difficult!

Page 40: Lecture0.ppt

A Bright IdeaA Bright Idea

Devise a set of abbreviations (mnemonics) Devise a set of abbreviations (mnemonics) corresponding to the ML statements, plus corresponding to the ML statements, plus a program to translate them into ML.a program to translate them into ML.

The abbreviations are an The abbreviations are an assembly assembly languagelanguage, and the program is called an , and the program is called an assemblerassembler..

Assembler 0010111010110101ADD

Page 41: Lecture0.ppt

Assembly LanguagesAssembly Languages

Allowed a programmer to use Allowed a programmer to use mnemonics, which were more mnemonics, which were more natural than binary.natural than binary.+Much easier to read programsMuch easier to read programs

+Much easier to find and fix mistakesMuch easier to find and fix mistakes

– Still not portable to different machinesStill not portable to different machines

Page 42: Lecture0.ppt

High Level LanguagesHigh Level Languages

Devise a set of statements that are Devise a set of statements that are close to human language (if, while, close to human language (if, while, do, ...), plus a program to do, ...), plus a program to translate them into ML.translate them into ML.

The set of statements is called a The set of statements is called a high high level languagelevel language (HLL) and the (HLL) and the program is called a program is called a compilercompiler..

Page 43: Lecture0.ppt

HLL CompilersHLL Compilers

Where an assembler translates one Where an assembler translates one mnemonic into one ML statement, mnemonic into one ML statement, a HLL compiler translates one HLL a HLL compiler translates one HLL statement into multiple ML statements.statement into multiple ML statements.

Compiler

1010110011110101

0000000000010000

0010111010110101

0000000000010010

0010111011111101

0000000000010100

z = x + y;

Page 44: Lecture0.ppt

HLLsHLLs

High level languages (like C++) areHigh level languages (like C++) are+Much easier to read programsMuch easier to read programs

+Much easier to find and fix mistakesMuch easier to find and fix mistakes

+Portable from one machine to another Portable from one machine to another (so long as they keep to the language (so long as they keep to the language standard).standard).

Page 45: Lecture0.ppt

Objectives in Objectives in ProgrammingProgramming

A program should solve a problem:A program should solve a problem:+correctlycorrectly (it actually solves the problem) (it actually solves the problem)

+efficientlyefficiently (without wasting time or space) (without wasting time or space)

+readablyreadably (understandable by another (understandable by another person)person)

+in a in a user-friendlyuser-friendly fashion fashion (in a way that is easy for its user to use).(in a way that is easy for its user to use).

Page 46: Lecture0.ppt

SummarySummary

A computer has two kinds of components:A computer has two kinds of components:– Hardware: its CPU, RAM, Disk(s), ...Hardware: its CPU, RAM, Disk(s), ...

– Software, its OS, Applications, and User Programs.Software, its OS, Applications, and User Programs.

There are “levels” to computer languages:There are “levels” to computer languages:– ML consists of “low” level binary statements, that is ML consists of “low” level binary statements, that is

hard to read, write, and not portable.hard to read, write, and not portable.

– Assembly uses “medium” level mnemonics: easier to Assembly uses “medium” level mnemonics: easier to read/write, but not portable.read/write, but not portable.

– C++ is a “high” level language that is even easier to C++ is a “high” level language that is even easier to read/write, read/write, andand portable. portable.