I. Definition and Essence of Computers
1. What Is a Computer?
A computer is an electronic device capable of automatically processing, storing, transmitting, and outputting data according to predefined instructions.
From the perspective of computer science, a computer is not merely a machine that performs mathematical operations, but a programmable general-purpose information processing system.
To understand computers, several basic concepts must first be clarified:
Concept | Definition |
|---|---|
Data | The objects that a computer processes, which may be numbers, text, images, sound, etc. |
Instruction | A basic command that tells the processor what operation to perform |
Program | A set of instructions organized according to certain rules |
Hardware | The physical devices in a computer that can actually run and operate |
Software | The collection of programs, data, and related documentation |
Computation | The process of transforming input data according to certain rules and producing results |
These concepts form the foundation for understanding computer systems.
2. Core Characteristics of Computers
What distinguishes a computer from ordinary electronic devices is not whether it can perform computations, but whether it possesses the following capabilities:
Programmability: The behavior of the device can be changed by modifying the program.
Automatic execution: It can automatically execute tasks according to a sequence of instructions.
Data processing: It can encode, compute, and convert different types of data.
Storage capability: It can save programs and data and read them when needed.
Generality: Within the limits of its hardware capabilities, it can accomplish different tasks through different programs.
Among these, the most important are programmability and generality.
A computer does not need to be redesigned at the hardware level for every task. As long as the hardware instruction set and system resources can support it, completely different work can be accomplished by replacing or running different software.
For example, the same computer can run a browser, a database, a compiler, image processing software, and artificial intelligence models.
This is the most important difference between general-purpose computers and special-purpose computing devices.
II. What Can Computers Actually Do?
From the perspective of computer system functions, their core capabilities can be summarized in the following aspects.
Capability | Main Content | Typical Scenarios |
|---|---|---|
Computation | Arithmetic operations, logical operations, numerical analysis | Scientific computing, financial computing |
Storage | Data reading, writing, and persistence | File systems, databases |
Information processing | Encoding, conversion, compression, retrieval | Image processing, data analysis |
Control | Controlling execution processes according to programs and conditions | Automated control, device management |
Communication | Data sending, receiving, and exchange | Network communication, distributed systems |
Human-computer interaction | Receiving input and outputting processing results | Graphical interfaces, command lines, voice interaction |
These capabilities are not independent of one another.
For example, when a web application processes a user request, it typically involves:
The network module receives the HTTP request;
The CPU executes the application's instructions;
Memory holds runtime data;
The database reads or writes business information;
The network module returns the processing result to the client.
Therefore, an actual software system is usually the result of multiple computing capabilities working together.
III. Basic Working Principles of Computers
Understanding computers cannot stop at what they can do; it is also necessary to understand why they are able to accomplish these tasks.
One of the core ideas of modern general-purpose computers is the stored-program concept.
1. What Is a Stored Program?
The core of the stored-program idea is:
Program instructions and the data to be processed can both be stored in encoded form in the computer's memory, and the processor reads instructions from memory and executes them.
This means that a program is no longer a function fixed in hardware circuits, but data that can be loaded, stored, replaced, and executed.
For example:
A computer can first load a browser program and perform web browsing tasks; then exit the browser, load a database program, and perform data management tasks.
The hardware has not fundamentally changed; what changes is the program being loaded and executed.
This gives computers a high degree of flexibility and generality.
2. The Von Neumann Architecture
The classic Von Neumann architecture divides a computer into several core components:
Arithmetic Logic Unit (ALU): Performs arithmetic and logical operations.
Control Unit: Controls the instruction execution process.
Memory: Stores programs and data.
Input devices: Provide data to the computer.
Output devices: Output computation results.
In modern teaching, the arithmetic logic unit and the control unit are usually collectively called the central processing unit (CPU).
The relationships among them can be understood through the following structure:
flowchart TB
IN(["Input Device<br/>Input"])
OUT(["Output Device<br/>Output"])
subgraph COMPUTER["Computer System"]
direction TB
subgraph CPU["Central Processing Unit CPU"]
direction LR
CU["Controller<br/>Control Unit"]
ALU["Arithmetic Unit<br/>ALU"]
CU <--> ALU
end
MEM[("Storage<br/>Memory<br/><br/>Programs and Data")]
CPU <-->|"Instructions and Data"| MEM
end
IN -->|"Input Data"| MEM
MEM -->|"Processing Results"| OUT
classDef io fill:#E0F2FE,stroke:#0284C7,color:#0C4A6E,stroke-width:1.5px
classDef cpu fill:#DBEAFE,stroke:#2563EB,color:#1E3A8A,stroke-width:1.5px
classDef memory fill:#DCFCE7,stroke:#16A34A,color:#14532D,stroke-width:1.5px
class IN,OUT io
class CU,ALU cpu
class MEM memory
style COMPUTER fill:#F8FAFC,stroke:#64748B,stroke-width:1.5px
style CPU fill:#EFF6FF,stroke:#2563EB
Note the following:
The von Neumann architecture is a classic model for understanding computers; it does not mean that all components of modern computers are connected strictly according to this simple structure.
Modern computers also contain many components such as cache, memory controllers, buses, DMA controllers, GPUs, and I/O controllers. The actual architecture is far more complex than this model.
But this model is still very important, because it explains the most basic working idea of modern general-purpose computers: programs and data enter the storage system, the processor performs calculations according to instructions, and ultimately produces results.
3. How Are Instructions Executed?
The CPU does not directly understand the Java, Python, or C++ code we write.
These high-level languages need to go through processes such as compilation or interpretation to be converted into machine instructions that the processor can execute, or to be further executed by a runtime environment.
From the perspective of the processor's basic working mechanism, the execution of an instruction can usually be abstracted into the following stages:
Fetch: Read the next instruction from the instruction storage location.
Decode: Parse the instruction and determine the operation to be performed and its operands.
Execute: Perform operations such as arithmetic, logic, memory access, or control transfer.
Memory Access: Read or write data as required by the instruction.
Write Back: Write the execution result to a target location such as a register.
Not all instructions go through exactly the same stages. Different processor architectures and different instruction types also have different specific execution flows.
A simplified instruction execution process is as follows:
%%{init: {
'theme': 'base',
'themeVariables': {
'fontFamily': 'Inter, Microsoft YaHei, sans-serif',
'fontSize': '14px',
'lineColor': '#A3B8AC',
'primaryTextColor': '#334155',
'mainBkg': '#FFFFFF'
},
'flowchart': {
'nodeSpacing': 20,
'rankSpacing': 22,
'padding': 8,
'htmlLabels': true,
'curve': 'linear'
}
}}%%
flowchart TB
A(["Program loaded into memory"])
B["CPU fetches instruction<br/>Fetch"]
C["Instruction decoding<br/>Decode"]
D["Perform operation<br/>Execute"]
E["Read or write data<br/>Memory Access"]
F["Save execution result<br/>Write Back"]
G["Fetch next instruction"]
A --> B
B --> C
C --> D
D --> E
E --> F
F --> G
G --> B
%% Uniform node size and spacing
classDef base min-width:220px,padding:9px,stroke-width:1.5px,rx:8,ry:8
%% Fresh, natural color scheme
classDef start fill:#DCFCE7,stroke:#86CDA0,color:#166534
classDef fetch fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
classDef decode fill:#F0EAFE,stroke:#B9A5E4,color:#59427D
classDef execute fill:#DDF5EE,stroke:#85CBB5,color:#245E4D
classDef memory fill:#FFF4D9,stroke:#E8C77D,color:#79551D
classDef writeback fill:#F1F4F2,stroke:#B4C1B9,color:#47574D
class A,B,C,D,E,F,G base
class A start
class B,G fetch
class C decode
class D execute
class E memory
class F writeback
linkStyle default stroke:#A3B8AC,stroke-width:1.5px
The CPU repeats this process continuously until the program ends, an exception occurs, or a control transfer is executed.
To improve performance, modern processors also use techniques such as pipelining, out-of-order execution, branch prediction, and multi-core parallelism. Therefore, actual execution is not always simply completed one instruction after another in serial order.
This is also something that needs to be understood in depth when studying CPU architecture later.
IV. Why Can Computers Process Different Types of Information?
Internally, a computer is mainly composed of digital circuits, whose foundation is binary.
1. Binary: The Foundation of Computer Data
Internally, computers use binary (Binary) to represent data.
Binary has only two basic digits:
0
1
In digital circuits, different voltage states can be used to represent logic 0 and logic 1.
For example, one binary digit (Bit) can be represented as 0 or 1.
When multiple binary digits are combined, they can represent richer information.
Unit | Meaning |
|---|---|
bit | Binary digit, the smallest unit of information representation |
Byte | Byte, usually 8 bits |
KB | Usually represents 1024 bytes (in some contexts, the decimal definition is used) |
MB | Usually represents 1024 KB (in some contexts, the decimal definition is used) |
GB | Usually represents 1024 MB (in some contexts, the decimal definition is used) |
TB | Usually represents 1024 GB (in some contexts, the decimal definition is used) |
Strictly speaking, KB, MB, GB, and TB in the International System of Units are decimal units, corresponding to multiples of 1000 respectively; only KiB, MiB, GiB, and TiB are multiples of 1024.
2. How Are Different Types of Data Represented?
Computers do not directly understand text, images, or sound.
They need to convert this information into binary data through encoding rules.
For example:
Numbers: represented using binary numeric values.
Text: represented through character encoding, such as UTF-8.
Images: represented through data such as pixels and color channels.
Sound: converted into digital audio through sampling, quantization, and encoding.
Video: usually composed of consecutive image frames and audio data, then encoded and compressed.
Therefore, when computers process different types of information, they are essentially processing binary data.
Special attention should be paid to:
Binary is only a way to represent data; it is not equal to the business meaning of the data itself.
The same string of binary data, if interpreted using different encoding rules, may represent numbers, characters, instructions, or image data.