CS 102 Lecture Notes
Week One, Thursday: Introduction (cont.)
What is a Computer?
Something that computes, but let's try to go past this circular definition. According to DD, "A computer is
a device capable of performing computations and making logical
decisions..." Artificial computers can do this at very high speeds. What is computation?
Performing algorithms. What is an algorithm? A finite set (often, but not limited to, a sequence) of actions
on things ordered to achieve a desired result.
Therefore a computer is something that performs actions on things purposefully. That is,
computation is action that has the appearance of intelligence. Algorithms can be executed
in the physical world (sorting a hand of cards, for example) or in a purely symbolic world,
such as in the human mind or in an artificial computer.
Applying this definition, anything that performs actions purposefully can be considered to be a
computer (or to have a computer component). For example, the brain of a shark that cruises around
looking for prey can be considered a natural computer. This course is concerned with programming
artificial computers.
Computer Organization
Generally, modern artificial computers have six components:
- Input unit (mouse, keyboard, microphone, camera).
- Output unit (screen, printer, speaker, actuator).
- Memory (hierarchy: on-CPU cache, secondary cache, RAM, VM).
- Arithmetic and logic unit (ALU).
- Central processing Unit (CPU).
- Secondary storage (disk).
Evolution of Operating Systems
Batch systems. Multiprogramming. Timesharing.
Personal, Distributed, and Client/Server Computing
Standalone PCs. Apple, IBM. Local area network (LAN)), client-server: file server,
database server. Distributed computing.
Languages: Machine, Assembly, and High Level
Comuter languages evolved toward a higher level in order to improve programmer
productivity.
History of C and C++
BCPL (1967, Martin Richards), B (1970, Ken Thompson), C (1972, Dennis Ritchie),
C++ (1980, Bjarne Stroustrup).
C++ Standard Library
iostream.h, iomanip.h, math.h, ctype.h, stdlib.h, string.h, etc.
Java, the Internet, and the World Wide Web
Java is more portable (compile once, run everywhere) and simpler than C++,
but most of the syntax is very similar. Learning C++ will prepare you for
the higher level Java language. Java makes programming Internet and Web
applications relatively easy.
Arithmetic
Consider the algebraic expression
y = mx + b
This can be expressed in C++ code as
y = m * x + b;
This is an example of "mapping a concept to code." In this example, the
C++ code is exactly the same as the equivalent C code.
Thinking about Objects
Human beings use abstraction as a routine part of thought processes. Thinking
about objects is an example of one major way people think abstractly. C++
and other object-oriented languages allow us to map our object thinking
to code in a natural way. Objects have attributes (member data) and actions
(member functions).
Elevator Problem Statement
A two-floor elevator with a one-person capacity! Smallest subset of the
general prolem. Simulate the random arrival of people on the two floors.
Person pushes button for destination floor (only one choice). Bell
sounds and floor light comes on when elevator arrives. Elevator takes
five seconds to go to the next floor.
This page established August 30, 1999; last updated Jan 6, 2000.