Abstract Computers

Abstractly, we can understand a physical or virtual machine in terms of its components, data types, and instruction set:

Computer = Components + Data Types + Instruction Set

Components

Components can be hardware or software components.

The main components are processor, memory, and an optional user interface. These components can communicate with each other through a bus or network:

Memory

Memory is where the computer's data and programs are stored.

Memory can be divided into a small, fast, but volatile main memory, and a large, slow, static secondary memory:

Volatile means the contents of memory are lost when the computer shuts down. This is not the case with static memory.

At the hardware level memory can be viewed as a vast array of bytes.

In a virtual machine memory can be more abstract. Here are some examples:

Variables

Data Structures (stacks, queues, hash tables, trees, arrays, lists)

Files (text, binary, executable)

Processor

The processor can be viewed as a particular program implemented in software or hardware. This program is called the Fetch-Execute cycle:

1. instruction = fetch next instruction from memory
2. if (instruction == halt) quit
3. arguments = fetch needed data from memory
4. result = execute instruction with arguments
5. store result into memory
6. goto 1

User Interfaces (Optional)

There are two types of user interfaces.

Console User Interfaces (CUI)

The Read-Execute-Print Loop (REPL):

1. display prompt/menu
2. read command
3. if (command == quit) quit
4. result = execute command
5. print result
6. goto 1

Graphical User Interfaces (GUI)

A GUI can be viewed as a tree of windows and controls:

Example:

 

A GUI is driven by a user input event loop:

1. wait for a user command (menu selection, button click, etc.)
2. if (command == quit) quit
3. execute command
4. repaint views
5. goto 1

Data Types

A computer can be viewed as a data processing machine. The forms of data that can be processed are organized into types. Here are some examples:

Primitive Data
   Bits (0, 1), Bytes (8 Bits), Words (2, 4, 8, ... bytes)
   Numbers
      Exact Numbers (short, int, long)
      Inexact Numbers (float, double)
   Characters (ASCII, UNICODE)
   Booleans (true, false)
   Pointers, References
Composite Data
   Arrays
   Objects, Records, Structures
      Collections (Sets, Lists)
      Enumerations
User-Defined Data
   Bank, Account, AccountHolder, Transaction, etc.

Instruction Sets

The instructions a computer can execute are organized by what they do:

Data Control (assign, read, write)
Sequence Control (blocks, conditionals, iterations, escapes)
Arithmetic (+, *, -, /, %, <, <=, >, >=, ==)
Logic (&&, ||, !, &, |, ~)
Functions (call/return)
Declarations (of functions, data types, variables, etc.)