Chapter 1

Report
Chapter 1
Preliminaries
ISBN 0-321-49362-1
系譜
Genealogy of Common Languages
LISP
Java
BASIC
Pascal
FORTRAN
Copyright © 2004 Pearson Addison-Wesley. All rights reserved.
1-2
為何研究PL?
1.
2.
3.
4.
5.
6.
增進
增進
增加
獲得
更易
更易
開發有效率的演算法 之能力
對既存PL之瞭解與使用 之能力
有用的程式結構之詞彙
更好的PL之選擇
學習新PL
= grammar
設計新PL
(static)
Syntax L:
(dynamic)
Semantics = logic
一些重要影響 vs. 一些程式語言
影響
語言
1950-55:基本型電腦
組合語言和機器語言的程式
基本概念
副程式
資料結構
高階語言的可能發展
組合語言
實驗性的高階語言,但今天已
不被使用了
1956-60:小型、速度慢、昂貴的電腦
磁帶式的大量儲存系統
編譯程式
軟體意譯程式
碼最佳化
可動式的記憶管理
FORTRAN IV
ALGOL 58 and ALGOL 60
COBOL
LISP
1961-65:大型、昂貴的電腦
磁帶式的大量記憶系統
作業系統
多重程式
由語法決定的編譯程式
程式語言設計的一個目標:一般
目的
FORTRAN IV
COBOL 61 Extended
ALGOL 60 Revised
SNOBOL
APL(是一種概念,但並沒有實
行)
1966-70:可變大小、速度、費用,且具有
指令集合的攜帶型電腦
龐大及昂貴的記憶系統
分時,交互性的作業系統
微程式
最佳化的編譯程式
可以寫轉譯器的系統
第一代標準語言
語言設計目標: 可變及廣泛(一
般化)
PL/I
FORTRAN 66(標準)
COLBOL 65(標準)
ALGOL 68
SNOBOL 67
SIMULA 67
BASIC
APL 360
1971-75:微電腦
小且不貴的大量記憶系統
程式正確性的證明
結構化的程式
軟體工程
反對大且複雜的語言
語言設計目標:簡單化
Pascal
COLBOL 74(標準)
PL/I
1976-80:有效力且不貴的電腦
龐大及便宜的記憶系統
分散式的電腦系統
嵌入式的電腦系統
用高階語言設計平行,即時程式
交談式的程式環境
資料抽象化
軟體的組成要素
正規的語意定義
語言設計目標:維護的可靠性和
容易性
Ada
FORTRAN 77(標準)
影響PL設計之因素
計算機硬體與作業系統
2. 應用(領域)
3. 程式化方法
4. 開發方法
5. PL理論研究
6. 標準化
綜合上述,PL之歷史演進如表1-2.
1.
判定某一PL優於另一PL之因素:
1.
2.
3.
4.
5.
6.
7.
8.
語言概念之清晰、簡單與一致性
PL文法之簡要明瞭
應用上之自然
易於抽象化
易於證明正確性
程式化環境
可攜性
使用花費:
(a)程式執行上
(b)程式翻譯上
(c)程式產生、測試上 (d)程式維護上
(1) Imperative( procedural) language: This model follows from
the hardware of the conventional computer that executes
instructions sequentially.( e.g., C, C++, FORTRAN, ALGOL,
PL/I, Pascal, Ada, Smalltalk, and COBOL). Looks like :Stmt1;
stmt2; …
(2) Applicative( functional) language: looks like: funn(…
fun2(fun1 (data)..). Program development proceeds by
developing functions from previously developed functions to
build more complex functions that manipulate the initial set of
data until the final function can be used to compute an answer
from the initial data. (e.g., LISP and ML).
(3) Rule-based( logic programming) language: It executes by
checking for the presence of a certain enabling condition and,
when present , executing an appropriate action.
Looks like: enabling condition1  action1
enabling condition2  action2
......
Execution of a rule-based language is similar to an imperative
language except that statements are not sequential.
BNF parsing techniques and tools like YACC(Yet Another
Compiler Compiler) to parse programs are rule-based techniques
that use the formal syntax of the program as the enabling condition.
(e.g., Prolog is the most well-known language in this class).
(4) Object-oriented programming: In this class, complex data
objects are built, then a limited set of functions are designed to
operate on those data.
Complex objects are designed as extensions of simpler objects,
inheriting properties of the simpler object. As we show( in chapter
7), what is actually happening is that we are trying to use the best
of two of the other computational models. By building concrete
data objects, an object-oriented program gains the efficiency of
imperative languages. By building classes of functions that use a
restricted set of data objects, we build the flexibility and reliability
of the applicative model.
Programming Methodologies Influences
• 1950s and early 1960s: Simple applications; worry
about machine efficiency
• Late 1960s: People efficiency became important;
readability, better control structures
– structured programming
– top-down design and step-wise refinement
• Late 1970s: Process-oriented to data-oriented
– data abstraction
• Middle 1980s: Object-oriented programming
– Data abstraction + inheritance + polymorphism
Copyright © 2009 Addison-Wesley. All rights reserved.
多態性
1-14
Language Categories(another view)
• Imperative
– Central features are variables, assignment statements, and
iteration
– Include languages that support object-oriented programming
– Include scripting languages
– Include the visual languages
– Examples: C, Java, Perl, JavaScript, Visual BASIC .NET, C++
• Functional
– Main means of making computations is by applying functions to
given parameters
– Examples: LISP, Scheme
• Logic
– Rule-based (rules are specified in no particular order)
– Example: Prolog
• Markup/programming hybrid ( i.e. object-oriented prog)
– Markup languages extended to support some programming
– Examples: JSTL, XSLT
Ref. to next page
Copyright © 2009 Addison-Wesley. All rights reserved.
1-15
A markup language is a modern system for annotating a text in
a way that is syntactically distinguishable from that text. The
idea and terminology evolved from the "marking up" of
manuscripts, i.e. the revision instructions by editors, traditionally
written with a blue pencil on authors' manuscripts. Examples are
typesetting instructions such as those found in troff and LaTeX,
and structural markers such as XML tags. Markup is typically
omitted from the version of the text which is displayed for enduser consumption. Some markup languages, like HTML have
presentation semantics, meaning their specification prescribes
how the structured data is to be presented, but other markup
languages, like XML, have no predefined semantics
Read more: http://www.answers.com/topic/markuplanguage#ixzz1ErgYk1KO
Copyright © 2009 Addison-Wesley. All rights reserved.
1-16
Language Design Trade-Offs
• Reliability vs. cost of execution
– Example: Java demands all references to array elements
be checked for proper indexing, which leads to increased
execution costs
• Readability vs. writability
Example: APL provides many powerful operators (and a large
number of new symbols), allowing complex computations
to be written in a compact program but at the cost of
poor readability
• Writability (flexibility) vs. reliability
– Example: C++ pointers are powerful and very flexible but
are unreliable
Copyright © 2009 Addison-Wesley. All rights reserved.
1-17
Implementation Methods
• Compilation
– Programs are translated into machine language
• Pure Interpretation
– Programs are interpreted by another program known as
an interpreter
• Hybrid Implementation Systems
– A compromise between compilers and pure interpreters
Copyright © 2009 Addison-Wesley. All rights reserved.
1-18
Summary
• The study of programming languages is valuable for
a number of reasons:
– Increase our capacity to use different constructs
– Enable us to choose languages more intelligently
– Makes learning new languages easier
• Most important criteria for evaluating programming
languages include:
– Readability, writability, reliability, cost
• Major influences on language design have been
machine architecture and software development
methodologies
• The major methods of implementing programming
languages are: compilation, pure interpretation, and
hybrid implementation
Copyright © 2009 Addison-Wesley. All rights reserved.
1-19

similar documents