Introduction to Computing
Introduction
1
What is a Computer?
Computer
Device capable of performing computations
and making logical decisions (i.e. executing
instructions)
Super computers, PC, mobile phones, microwave
ovens, …
Vary mainly in terms of speed and resources
available
Same fundamental design
2
TPU
TPU
Computer Organization Memory
Input Unit GPU
Memory GPU
CPU
Arithmetic Storage Unit
& Logic
Unit Memory Unit
Control Communication
Unit Unit
Flow of data
Output Unit Bus(es)
3
Concept of Stored Program
A set of computer instructions forms a program
Programs can be stored in some form for future
use and for repeated invocation
Early computers could not store a program, thus
operators had to issue instructions repeatedly
Later on, programs can be stored using devices
and circuits
4
von Neumann Architecture
Basis of modern computer design
Data and program are both stored in the
computer's memory in the same address
space
Memory centric
5
Computer Organization
1. Input unit
Obtains information from input devices
Keyboard, mouse, microphone, scanner, camera, …
2. Output unit
Takes information processed by computer
Places information on output devices
Screen, printer, 3D printer, speaker, …
Information used to control other devices
6
Computer Organization
3. Central processing unit (CPU)
CU (Control Units)
Supervises and coordinates other sections of
computer
Arithmetic and logic unit (ALU)
Performs arithmetic calculations and logic
decisions
7
Computer Organization
4. Memory unit (= Primary Memory = Main Memory)
Rapid access, relatively low capacity “warehouse”
section
Retains information from input/ storage/
communication unit
Immediately available for processing
Retains processed information
Until placed on output/ storage/ communication devices
Refers to the Random Access Memory (RAM)
8
Computer Organization
5. Secondary storage unit
Long-term, high-capacity “warehouse” section
Storage
Data and programs that are not immediately needed
Secondary storage devices
Disks, Optical discs, Solid-state memory drive
Longer to access than primary memory
Speed: MB/s; Latency: ms
Less expensive per unit than primary memory
Cost: $/GB
9
Computer Organization
Communication unit/ device/ technology
Ethernet (IEEE 802.3)
Blue-tooth, NFC, RFID, …
Wi-Fi (IEEE 802.11a/b/g/n/ac)
Wi-Max
Infra-red
Fibre-optics
GSM, 3G, 4G, 5G, …
HTTP/S, FTP, BT, SSH, …
10
Memory Organization
In the lowest level, computers understand only
0's and 1's.
Computer memory stores a sequence of 0's and
1's.
Each such storage unit is called a bit.
Eight bits are grouped together to form a larger
storage unit called a byte.
11
Memory Organization (con't)
Each byte has a unique address for identification.
Computer memory can thus be viewed as a series
of bytes.
12
What is a Computer Program?
Computer programs
Sets of instructions that tells the computer
how to process the data
Writing computer programs means writing sets
of instructions in some languages that tell the
computer what to do.
13
Machine Languages
Language that a computer directly understands
Defined by hardware design
Machine-dependent
Made up of 0s and 1s
Instruct computers to perform elementary operations
One at a time
Example:
00010101000101010100010110000001 means add a & b
10100101011010101010101010101010 means jmp loc
00000011111100000011111100000010 means int 21h
Cumbersome( 笨重,累赘。麻烦 ) for humans
14
Assembly Languages
English-like abbreviations representing
elementary computer operations
Easier for humans to read and write
Incomprehensible to computers
Translator programs (assemblers)
Convert to machine language
Example:
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
Still quite troublesome to use 15
High-Level Languages (HLL)
More English-like, use common mathematical
notations
Single statements accomplish substantial tasks
Assembly language requires many instructions to accomplish
simple tasks
An example HLL statement:
grossPay = basePay + overTimePay
16
High-Level Languages (HLL)
HLL Compilation and Interpretation
The process of translating HLL programs to machine
code (or object code, intermediate code, binary
code)
Done by Hand! – during early development phases
Done by Compilers – software translator
Result is usually saved in a binary file, e.g., object file
Interpreters – a special form of compiler
Translate high-level language programs AND
Execute (run) directly 17
High Level Languages
Different high-level languages were
designed to serve different purposes
Basic, Pascal, C, C++, C#, Java, Fortran,
Perl, Lisp, Cobol, PHP, JavaScript, …
18
History of C and C++
History of C
Evolved from two other programming languages
BCPL and B
Dennis Ritchie (Bell Laboratories)
Added data typing, other features
Development language of UNIX
Hardware independent
Portable programs
1989: ANSI standard
1990: ANSI and ISO standard published
ANSI/ISO 9899: 1990
19
History of C and C++
History of C++
Extension of C
Early 1980s: Bjarne Stroustrup (Bell Laboratories)
Provides capabilities for object-oriented programming (OOP)
Objects: reusable software components
• Model items in real world
Object-oriented programs
• Easy to understand, correct and modify
Hybrid language
C-like style
Object-oriented style
Both
20
Other High Level Languages
Java (now under Oracle Corporation)
1991: Sun Microsystems
Green project
1995: Sun Microsystems
Formally announced Java at trade show
OOP, C-like syntax, compact, portable, rich set of
libraries, and secure.
Web pages with dynamic and interactive content (Applet)
Develop large-scale enterprise applications
Enhance functionality of web servers
Provide applications for consumer devices
• Cell phones, pagers, personal digital assistants, …
21