A Balanced Introduction to Computer Science and Programming

David Reed
Creighton University

Copyright © 2004 by Prentice Hall



Chapter 1: Computer Basics


Computers are incredibly fast, accurate, and stupid: humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination. Albert Einstein

Albert Einstein

Computers are to computing as instruments are to music. Software is the score whose interpretations amplifies our reach and lifts our spirits. Leonardo da Vinci called music the shaping of the invisible, and his phrase is even more apt as a description of software.

Alan Kay


The easiest way to tell the difference between hardware and software is to kick it. If it hurts your toe, it's hardware.

Carl Farrell


The computer, as we think of it today, is a relatively new technological development. The first electronic computers were built in the 1940's, and desktop computers that were accessible by everyday people date back only to the late 1970's. In a very short time, computers have become integral to the way that businesses work and people interact. But while many people use computers for work and pleasure everyday, few have even a basic understanding of how they work.

This chapter presents an overview of computer technology, focusing on what computers are, how they are organized, and what they can do. The coverage in this chapter is not meant to be exhaustive - many of the topics introduced here will be revisited in later chapters. However, the knowledge gained from this overview should provide a framework for understanding computing concepts as you encounter them, and also make you a wiser consumer of computer technology.


What is a computer?

When you think of the word "computer", you probably picture a machine that sits on a desk and is used to create documents, send email, or explore the World Wide Web. This type of computer may be referred to as a personal computer since it is designed for use by a single person, or alternatively as a desktop computer since it is small enough to fit on the top of a desk. While the personal computer is the most common image of computers today, it is by no means the only one. Some computers, known as supercomputers, are large enough to take up an entire room and have the computing power to perform trillions of calculations per second. Other computers are smaller, such as laptops that fit in a briefcase or even palmtops that fit in your hand. In addition, there are millions of small computers embedded in everyday devices such as automobiles, air conditioners, and microwave ovens.

various computers

What all of these machines have in common, what makes them computers, is that they receive, store, and process information. A personal computer is able to read in data, store it in files, and process that data to produce a document or spreadsheet or email message. Likewise, the embedded computer in the anti-lock brakes of a car is able to sense the spin of the wheels, process that data to compute the optimal braking pattern, and direct the car to a safe stop.

Despite the fact that computers are pervasive in everyday life, few people have even a basic understanding of how computers are organized and perform their tasks. Even purchasing a personal computer can be an overwhelming experience involving highly technical information and obscure computer jargon. For example, the following table is based the advertised specifications of two desktop computer systems by a major computer manufacturer (August, 2002). System 1 is a low-end computer system, inexpensive but with limited features and utilizing older technology. System 2 is a high-end computer, maximizing performance using the latest technology but at a higher cost. Understanding the tradeoffs between these two models requires a significant amount of computer knowledge. And this is a streamlined version of only one table of options for only one category of computer system for only one company!


    Desktop System 1   Desktop System 2
CPU 1.4GHz Intel Celeron Processor 2.533GHz Intel Pentium 4 Processor
Cache 256KB Cache 512KB Cache
RAM 128MB RAM 1GB RAM
Hard Drive 20GB Hard Drive 120GB Hard Drive
Floppy Drive 3.5" 1.44MB Diskette Drive 3.5" 1.44MB Diskette Drive
CD-ROM/DVD 40x/12x/48x CDRW DVD-RAM/DVD-R Drive and 48x/24x/48x CDRW
Keyboard Multifunction Keyboard Multifunction Keyboard
Pointing Device Optical Wheel Mouse Optical Wheel Mouse
Screen 17" Color Monitor 18" LCD Flat Panel Display
Speakers Speakers 5-piece Sound System
Modem 56K Modem 56K Modem
Network Adapter 10/100 Ethernet Adapter 10/100 Ethernet Adapter
Operating System Microsoft Windows XP Home Edition Microsoft Windows XP Home Edition
Applications Microsoft Works Suite 2002 Microsoft Office XP Small Business
Quicken New User Edition
Norton Anti-Virus Software

A first step toward an understanding of what computers are and how they work is distinguishing between hardware and software. The term hardware refers to the physical components of the computer, such as the monitor, keyboard, hard drive, etc. Software refers to the programs that execute on the computer, carrying out tasks such as word processing or accessing the Web. In the table above, the first three sections (starting with CPU and ending with Network Adapter) refer to hardware components of the systems. The last section (containing Operating System and Applications) refers to software components.


Hardware

Since computers can take on so many different forms, it is difficult to present a single picture of computer hardware. Even focusing on desktop computers, outward appearances can vary considerably in packaging and in the selection of components. The picture below shows a common desktop computer, with its hardware components labeled.

personal computer hardware

While the specific components and their appearance may vary from computer to computer, virtually all modern computers have the same underlying structure. This structure is known as the von Neumann architecture, named after computer science pioneer John von Neumann who formalized it in the early 1950's. The von Neumann architecture identifies three essential components that work together to function as a computer (i.e., a device that receives, stores, and processes information). The Central Processing Unit (CPU) performs the actual processing of information and serves as the "brains" of the computer. Memory stores information for processing, as well as program instructions that specify the processing steps that are to take place. Input/Output devices allow the user to communicate with the computer, entering commands and viewing the results. Each of these components will be discussed in more detail below.

von Neumann Architecture

Central Processing Unit (CPU)

The Central Processing Unit (CPU) is the brains of the computer, responsible for controlling the internal workings of the machine. You will learn more about how the CPU works in Chapter 14. However, for now it suffices to understand that the CPU is responsible for two key tasks. First, it contains the circuitry for performing a variety of calculations (such as adding or multiplying numbers) and manipulations (such as shifting or combining bit patterns). Thus, when information needs to be processed, the CPU carries out the actual computations to process the information. Second, the CPU is responsible for fetching and executing instructions that specify the tasks to be completed by the computer.

Prior to acceptance of von Neumann's design, computers were designed and built to perform a single task, such as computing the trajectory of a specific rocket under specific atmospheric conditions. If you wanted to perform a different task, you had to rewire and reconfigure the machine! Utilizing the von Neumann architecture, however, a series of computations for carrying out some task can be specified as a program and stored in memory. The CPU fetches the program instructions from memory and carries out the specified calculations/manipulations in order to perform the desired task. Performing a different task simply requires loading a new program into memory. In fact, the von Neumann architecture allows for multiple programs to reside in memory at the same time, enabling the CPU to juggle multiple tasks, such as switching back and forth between a Web browser and a text editor.

The CPU is by far the most complex component of a computer system. The Intel Pentium 4 processor, for example, contains electronic circuitry with more the than 42 million individual components. All of this circuitry is packaged onto a small silicon chip encased in plastic, with metal pins for connecting the chip to other hardware components. Common CPUs include the Intel Pentium 4, AMD Athlon, and Motorola PowerPC G4.

CPU chips

Each of the computers in the above table contains a CPU manufactured by the Intel Corporation. They differ in their speed and power.

Memory

The memory is that part of a computer that stores programs and data. Modern computers are digital devices, meaning they store and process data as discrete rather than continuous values. The building block of digital memory is the binary digit or bit, which can represent one of two values. Usually the two values of a bit are written as 0 and 1, but the values could just as easily be represented as off and on, open and closed, volts and no volts, etc.

Of course, a single bit is not very useful for storing information, since it can only differentiate between two different values. If you combine two bits, however, there are four different patterns that can be used to represent values: 00, 01, 10, and 11. Three bits are able to represent eight values using the patterns: 000, 001, 010, 011, 100, 101, 110, and 111. In general, a collection of N bits can represent 2N different values.

1 bit	--> 2 values        0 1
2 bits	--> 4 values        00 01 10 11
3 bits	--> 8 values        000 001 010 011 100 101 110 111
4 bits	--> 16 values       0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 ...
5 bits	--> 32 values       00000 00001 00010 00011 00100 00101 00110 00111 ...
6 bits	--> 64 values       000000 000001 000010 000011 000100 000101 000110 ...
7 bits	--> 128 values      0000000 0000001 0000010 0000011 0000100 0000101 ...
8 bits	--> 256 values      00000000 00000001 00000010 00000011 00000100 ...
9 bits	--> 512 values      000000000 000000001 000000010 000000011 000000100 ...
10 bits	--> 1,024 values    0000000000 0000000001 0000000010 0000000011 ...
.
.
.	
N bits	--> 2N values

While the bit is the building block of digital memory, memory capacity is usually specified in bytes. A byte is a collection of 8 bits, and thus is capable of representing 28 = 256 different values (which is sufficient for many ranges of values, e.g., the characters on a keyboard). Collections of bytes can be identified using prefixes: a kilobyte (KB) is roughly one thousand bytes of storage, a megabyte (MB) is roughly 1 million bytes of storage, and a gigabyte (GB) is roughly one billion bytes of storage. More specifically,

byte  --> 8 bits
kilobyte (KB) 	--> 210 bytes  = 1,024 bytes  ( = 8,192 bits)
megabyte (MB)	--> 220 bytes  = 1,048,576 bytes  ( = 8,388,608 bits)
gigabyte (GB)	--> 230 bytes  = 1,073,741,824 bytes  ( = 8,589,934,592 bits)

Since a byte is sufficient to store a single character, it may be instructive to think of memory capacity in terms of text. A kilobyte (KB) is capable of storing more than one thousand characters of text (e.g., an essay), a megabyte (MB) is capable of storing more than one million characters of text (e.g., a book), and a gigabyte is capable of storing more than one billion characters of text (e.g., a small library). While these capacities may seem large with respect to text, storing data other than characters can require extensive memory. For example, a high-resolution photograph might require several megabytes of storage, the audio track of a single song might require as much as 50 megabytes, and a full-length video might require gigabytes worth of storage.

While we may think of memory as a single logical unit, computers tend to incorporate several different types of memory, each with its own performance and cost characteristics. The fastest technology for storing bits uses electronic circuitry, with 1 and 0 represented as the presence or absence of voltage over a circuit. Cache (which may be packaged directly on the CPU chip) and RAM (short for Random Access Memory, which is packaged separately on its own chip) are examples of this type of electronic memory. Since values are stored within the circuitry as voltages, access is essentially limited by the speed of electricity and proximity to the CPU. Cache memory, being packaged directly on the CPU chip and utilizing more advanced technology, is usually faster than RAM and so is used to store the most critical data. However, cache is more expensive than RAM, so cost and performance are balanced with a small amount (usually measured in kilobytes) of cache and a larger amount (usually measured in megabytes) of RAM.

Cache and RAM together form the main memory (or primary memory) of a computer. This name refers to the fact they are the main storage for the CPU, the only memory to which the CPU has direct access. Before any data or instructions can be accessed by the CPU, that information must be loaded into primary memory (either cache or RAM, or both). But while main memory is fast, its high cost limits the amount that can be used in practice. In addition, main memory is volatile, meaning that it requires a constant flow of electricity to maintain its stored values. When you turn off a computer, the values stored in cache and RAM are lost. Thus, computers require secondary memory that is less expensive and permanent.

Secondary memory comes in a variety of technologies. A hard disk is a rotating metal platter that stores bits as magnetized and non-magnetized sectors. While this technology is considerably slower than memory built from circuitry, it is much less expensive and is able to retain data without power. As such, a hard disk is capable of permanently storing vast amounts of information (usually measured in gigabytes), which can be transferred into primary memory when needed. Floppy disks and CDs are examples of inexpensive, portable secondary memory. A floppy disk is a smaller, portable version of a hard disk, storing up to 1.44 MB of data on a 3.5" plastic disk. A CD (Compact Disk) is a metal disk that stores up to 700 MB of data as patterns on the reflective surface. Using CD-ROM (Compact Disk - Read Only Memory) technology, the patterns are burned onto the surface of the disk with a laser, implying that the disk can only be written to once. Using CDRW (Compact Disk - ReWritable) technology, patterns are formed in a photosensitive coating on the surface of the disk, allowing data to be overwritten repeatedly.

memory technologies

Each of the computers in the above table contains the full range of memory types, from cache and RAM down to floppy disk and CD. They differ primarily in the amount of each type of memory and some technical details.

Input/Output devices (I/O)

Clearly, a computer is not very useful if it is not able to communicate with the outside world. Input devices allow the computer to receive data and instructions from an external source, whether it be a person or another machine. Examples of input devices are keyboards, mice, track pads, microphones, and scanners. Similarly, output devices allow the computer to display or broadcast its results. Examples of output devices are monitors, printers, and speakers. Devices that allow the computer to communicate with other computers, whether in a local network or over the Internet, are both input and output devices. Examples include modems, Ethernet adapters, and wireless networking adapters.

Since input and output devices connect a computer and its user, the technology in this area is constantly changing to make interacting with a computer easier. For example, the introduction of the mouse as an input device was key to the popularization of computers in the 1980's. Similarly, improvements in flat-screen technology made smaller and lighter laptops computers affordable in the 1990's. Today, wireless networking technology is becoming prevalent, allowing for email and Web access through Personal Digital Assistants (PDAs) and cellular phones.

Each of the example computer systems in the above table includes an assortment of input/output devices, including a keyboard and mouse for input, a screen and speakers for output, and a modem and Ethernet adapter for communications.


Software

While hardware refers to the physical components of the computer, the term software refers to the programs that execute on that hardware. A software program is a collection of instructions for the computer to carry out in order to complete some task. For example, word processors such as Microsoft Word and Corel WordPerfect contain instructions for creating and managing documents; graphics programs such as Adobe Photoshop and Macromedia Flash contain instructions for the creation and display of graphical images; Web browsers such as Microsoft Internet Explorer and Netscape Communicator contain instructions for accessing and displaying Web pages. Programs such as these are known as applications software since each is designed to carry out tasks within a particular application area. Since computers are used in a variety of application areas, it is not surprising that there is a wide variety of applications software available.

The largest and most integral software on a computer is its operating system. An operating system is a collection of programs that controls how the CPU communicates with other hardware components, and also makes the computer easier for people to use. The operating system manages the execution of all application programs, controlling how data and instructions are loaded into memory and accessed by the CPU. It connects all of the hardware components with the software, allowing applications to seamlessly print or receive input from the keyboard. In addition, the operating system provides an interface for the user to interact with the computer. Most operating systems, including Microsoft Windows and Mac OS, utilize a Graphical User Interface (GUI) in which files and programs are represented as icons, multiple tasks can be carried out in separate windows, and user input can be specified using menus and mouse clicks.

Each of the example computer systems in the above table comes with the Microsoft Windows XP operating system and a suite of applications software.


Internet and the Web

Chapter 3 will describe the history and underlying structure of the Internet and the World Wide Web. Since you will begin developing Web pages in Chapter 2, however, a brief overview is worthwhile at this point.

Despite a common misconception, the Internet and the World Wide Web are not the same thing. The Internet is a vast, international network of computers. In the same way that an interstate highway crosses state borders and connects cities, the Internet crosses international borders and connects computers. The physical connections may vary, from high-speed dedicated cables to slow but inexpensive phone lines, but the effect is that a person sitting at a computer in Omaha, Nebraska (or wherever) is able to share information and communicate with a computer in Osaka, Japan (or wherever). The Internet traces its roots back to 1969, when the first long distance network connected computers at UCLA, UCSB, Stanford Research Institute, and the University of Utah. Through the 1970's and 1980's, the network that would eventually be known as the Internet grew steadily, but was limited mostly to government and academic users until the development of the World Wide Web in the 1990's.

While the Internet is made up of hardware (computers and their connections), the World Wide Web is a collection of software that spans the Internet and allows for the interlinking of documents and resources. The basic idea for the Web was proposed in 1989 by Tim Berners-Lee of the European Laboratory for Particle Physics (CERN). In order to allow distant researchers to share information more easily, his design allowed documents to be interlinked over the Internet and even incorporate multimedia elements such as images and sound clips. Through the use of machine-independent notation for specifying information (HTML) and a common set of rules for interpreting that notation (HTTP), documents could be shared across networks on various types of computers, allowing researchers to disseminate their research broadly. With the introduction of intuitive, graphical browsers in the mid 1990's, the Web became accessible to a broader public, resulting in the World Wide Web of today.

Internet vs. WWW

A Web page is nothing more than a text document that contains additional formatting information in a language called HTML (HyperText Markup Language). As you will experience in Chapter 2, all you need to create a Web page is a simple text editor and familiarity with the HTML language. To view a Web page with proper formatting, however, you need a special kind of computer program called a Web browser. The job of a Web browser is to access a Web page, interpret the HTML formatting information, and display the formatted page accordingly. The two most popular browsers on the market today are Microsoft's Internet Explorer and Netscape's Communicator.

Web Page

What makes the Web the "World-Wide" Web is that pages do not need to be stored on one particular computer, but instead can be distributed on computers all across the Internet. A Web server is a computer connected to the Internet that executes software for providing access to those documents. By placing Web pages within a public directory or folder on a Web server, those pages become accessible to all computers with Web browsers, regardless of their physical location on the Internet.

In order to succinctly and unambiguously specify the name and location of a Web page, each page is assigned a Uniform Resource Locator or URL. For example, the author's home page has the following address or URL:

Parts of a URL

When the user enters a URL into the Address box of the browser , the browser is instructed to find that page, download it over the Internet, and display it in the page. The browser uses the first part of the URL, the server name, to locate the Web server that stores the page. The rest of the URL allows the Web server to find the page within its directories. Once located, the page is sent back to the browser on the user's machine and displayed appropriately.

Parts of the URL are optional. For most browsers, if you omit the protocol prefix then http:// is assumed. Also, if the page name is omitted from the end of the URL, then the default name index.html is assumed. For this reason, it is common to have home pages named index.html so that the file name does not need to be remembered, just its location. Thus, the above link to the author's home page can be written as:

www.creighton.edu/~davereed

Similarly, the home page for Creighton University can be succinctly written as

www.creighton.edu which refers to the file named index.html in the main directory on the www.creighton.edu server.

As you develop your own Web pages, you will most likely want to store them locally (on a disk or on the hard drive of your computer) as you work on them. To load a local file, simply specify the name and directory path for that file, e.g., a:\sample.html.

Local Page

As the sample page demonstrates, Web pages can contain more than just text. The example page contains an image (a picture) and a hyperlink. A hyperlink (or link, for short) is a connection to another page, which is usually displayed in a Web page as underlined, colored text. For example, the above page contains a link labeled here. By clicking on a link within a page, the connected page is retrieved and loaded in the browser. In the above example, clicking on the link will load a separate page of personal information. By clicking on links, it is possible to navigate or "surf" the Web from one page to another. The buttons provided by the browser can be useful as you surf from page to page. For example, the Back button will take you back to the page you just came from.



Review Questions

Answers to be emailed to your instructor by Tuesday at 9 a.m.

  1. What is the difference between hardware and software?
  2. What are the three essential components of a computer that make up the von Neumann architecture?
  3. Modern computers integrate several different types of memory, such as cache, RAM, hard disk, and floppy disk. Why are different types of memory used, as opposed to the exclusive use of a particular technology? What would be the drawback, for example, of using only cache memory, or only hard disk?
  4. Computer memory is usually grouped in bytes, as in 128 megabytes of RAM memory or 20 gigabytes of hard drive memory. How much storage does a byte represent?
  5. The Intel Pentium 4 is an example of a processor or CPU, as are the Celeron and PowerPC. What does a CPU do?
  6. Windows 98 is an example of an operating system, as are the Mac OS and Linux. What does an operating system do?
  7. 7. It has been said that the Internet could exist without the Web, but the Web couldn't exist without the Internet. Why is this the case?
  8. How much of the table of computer system specifications did you find intelligible before reading the chapter? How about after?
  9. What did you find most interesting in reading this chapter?
  10. What did you find most confusing in reading this chapter?