NoteThe only language understood by a computer is machine language.
電腦唯一懂得語言就是機器語言。
Foundations of Computer Science (計算機概論) Chapter 9
Programming Languages (程式語言)
Outline
9.1 Evolution
(演化) 9.2 Building a program
(建構一個程式) 9.3 Program execution
(程式的執行)
Outline
9.4 Categories of languages
(語言的分類) 9.5 A procedural Language: C
(程序語言:C)
9.1
Evolution
(演化)
Evolution of Computer Languages
機器語言 符號式語言 高階語言 自然語言
(演化中)
Note
The only language understood by a computer is machine language.
電腦唯一懂得語言就是機器語言。
Evolution of Computer Languages
A symbolic language uses symbols to represent various machine language instructions (指令)一個符號語言使用符號來表示各樣的機器語言指令
Symbolic languages are also called assembly languages符號語言也可以稱為組合語言
Evolution of Computer Languages
High-level languages are portable (攜帶) to many different computers, allowing the programmer to concentrate (專注) on the application rather then the intricacies (錯綜複雜) of the computer高階語言可以攜帶到許多不同的電腦上執行,讓程式設計師可以專注於應用,而不是忙於電腦的一些瑣事
High-level languages (高階語言)
BASIC, Pascal, Ada, C, C++, and Java
Natural language (自然語言)
/* This program reads two integer numbers from the
keyboard and prints their product.
*/
#include
int main (void)
{
// Local Declarations
int number1;
int number2;
int result;
// Statements
cin >> number1;
cin >> number2;
result = number1 * number2;
cout << result;
return 0;
} // main 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
9.2
Building a Program
(建構一個程式)
Three Steps in Building a Program
Writing and editing the Program撰寫與編輯程式
Text edit (文字編輯器)
Source file (原始碼)
Compiling the program程式編譯
Preprocessor (前處理器)
Translator (轉譯器)
Object module (目的碼模組)
Linking the program with the required library modules將程式與所需要的函式模組連結
Subprogram (副程式)
Linker (連結器)
Building a Program
文字編輯器 編譯器 前處理器
轉譯器 連結器 系統函式庫 目的碼 原始碼
語言轉譯程式
Assembler (組譯器)
組合語言
Interpreter (直譯器)
Basic
Script language (JavaScript, VBScript)
Python
Perl
Compiler (編譯器)
FORTRAN
COBOL
Pascal
C
C++
Ada
Java
9.3
Program Execution
(執行的程式)
Program Execution
載入 輸入 輸出 Loader (載入器) Program (程式)
9.4
Categories of
Language
(語言的分類)
Categories of Language
Computer Language
電腦語言 Procedural
程序 Object-
Oriented
物件導向 Functional
函式 Declarative
宣告式 Special
特別
Procedural Language (程序語言)
A procedural language is a set of instructions that are executed one by one from beginning to end unless an instruction forces the control elsewhere一個程序語言是一組指令的集合,它們從頭到尾一一被執行,除非一條指令強迫控制到別處
When programmers need to solve a problem using one of the procedural language, they should know the procedure to follow當程式設計師要用程序語言解決問題時他們要先知道依序的程序
The programmer should carefully design an algorithm, and the algorithm should be carefully translated to instruction程式設計師該仔細的設計演算法,而演算法也應該小心的被轉換成指令
Comments