isbn 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学...

24
ISBN 0-321-19362-8 程程程程程程程程 谭谭谭 谭谭谭谭谭谭谭谭 谭谭谭谭谭谭谭谭谭 [email protected]

Upload: doris-watkins

Post on 17-Jan-2018

477 views

Category:

Documents


0 download

DESCRIPTION

1-3 教学环节和成绩评定 教学环节:课堂讲授 课外阅读 成绩评定:期末考试 + 偶尔点名

TRANSCRIPT

Page 1: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

ISBN 0-321-19362-8

程序设计语言原理谭文安

南京航空航天大学信息科学与技术学院

[email protected]

Page 2: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-2

主要参考书• Concepts of Programming Languages ( Sixth Edition ) Robert W. Sebesta ,机械工业出版社, 2002• 程序设计语言:设计与实现 Terrence W.Pratt, Matvin V.Zelkowitz 傅育熙,黄林鹏等译,电子工业出版社, 2002• 程序设计语言概念和结构 Ravi Sethi 著 , 裘宗燕等译,机械工业出版社, 2002• 程序设计语言原理 钱树人, 高等教育出版社, 2001

Page 3: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-3

教学环节和成绩评定

教学环节:课堂讲授 课外阅读 成绩评定:期末考试 + 偶尔点名

Page 4: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-4

Chapter 1 Topics

• Motivation• Programming Domains• Language Evaluation Criteria• Influences on Language Design• Language Categories• Language Design Trade-Offs• Implementation Methods• Programming Environments

Page 5: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-5

Motivation: Why Study Programming Languages?

• Increased ability to express ideas• Improved background for choosing

appropriate languages• Greater ability to learn new languages• Understand significance of implementation• Ability to design new languages• Overall advancement of computing

Page 6: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-6

Programming Domains• Scientific applications

– Large number of floating point computations– Fortran90 Algol60 …

• Business applications– Produce reports, use decimal numbers and characters– COBOL Language …

• Artificial intelligence– Symbols rather than numbers manipulated– LISP (函数式的) , Prolog 语言,逻辑程序设计

• Systems programming– Need efficiency because of continuous use– Unix OS, C 语言函数

• Scripting languages– Put a list of commands in a file to be executed– Shell 命令文件 ,…,JavaScript 语言 (Netscape)

• Special-purpose languages

Page 7: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-7

Language Evaluation Criteria

• Readability– The most important criteria– Factors:

• Overall simplicity– Too many features is bad ; count++; ++count, 运算符重载

• Orthogonality 正交性– Makes the language easy to learn and read– Meaning is context independent– A relatively small set of primitive constructs can be

combined in a relatively small number of ways– Every possible combination is legal– Lack of orthogonality leads to exceptions to rules

Page 8: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-8

Language Evaluation Criteria– Readability factors (continued)

• Control statements– Goto 语句

• Defining data types and structures– Boolean 变量定义 True/False 1/0– 数组定义 , 下标变量

• Syntax considerations– Identifier forms Fortran77 标示符长度 <=6– Special words Pascal 的 begin – end Ada 的 end if , end loop Fortran 90 中 , DO 和 END 是合法的变量名

Page 9: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-9

Language Evaluation Criteria

• Writability— 可写性– Factors:

• Simplicity and orthogonality• Support for abstraction( including data & procedure )• Expressivity 表达性

• Reliability— 可靠性– Factors:

• Type checking 函数调用参数传递• Exception handling 异常处理能力• Aliasing 别名使用是一个危险的特性• Readability and Writability

Page 10: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-10

Language Evaluation Criteria

• Cost– Categories

• Training programmers to use language• Writing programs• Compiling programs• Executing programs• Language implementation system• Reliability• Maintaining programs

Page 11: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-11

Influences on Language Design

• Computer architecture: Von Neumann We use imperative languages, at least in part,

because we use von Neumann machines– Data and programs stored in same memory– Memory is separate from CPU– Instructions and data are piped from memory to CPU– Basis for imperative languages

• Variables model memory cells• Assignment statements model piping• Iteration is efficient

Page 12: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-12

Von Neumann Architecture

Page 13: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-13

Influences on Language Design

• Programming methodologies– 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

Page 14: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-14

Language Categories

• Imperative -- 命令式语言– Central features are variables, assignment

statements, and iteration– C, Pascal

• Functional -- 函数式语言– Main means of making computations is by

applying functions to given parameters– LISP, Scheme

Page 15: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-15

Language Categories

• Logic -- 逻辑语言– Rule-based– Rules are specified in no special order– Prolog

• Object-oriented -- 面向对象语言– Encapsulate data objects with processing– Inheritance and dynamic type binding– Grew out of imperative languages– C++, Java

Page 16: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-16

Language Design Trade-Offs

• Reliability vs. cost of execution ( Eg. Ada )

• Readability vs. writability

• Flexibility vs. safety

Page 17: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-17

Layered View of Computer

Page 18: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-18

Implementation Methods

• Compilation– Translate high-level program to machine code– Slow translation– Fast execution

Page 19: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-19

Compilation Process

Page 20: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-20

Implementation Methods

• Pure interpretation– No translation– Slow execution– Becoming rare

Page 21: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-21

Pure Interpretation

Page 22: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-22

Implementation Methods

• Hybrid implementation systems– Small translation cost– Medium execution speed

Page 23: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-23

Hybrid Implementation System

Page 24: ISBN 0-321-19362-8 程序设计语言原理 谭文安 南京航空航天大学 信息科学与技术学院

1-24

Programming Environments

• The collection of tools used in software development

• UNIX– An older operating system and tool collection

• Borland JBuilder– An integrated development environment for

Java• Microsoft Visual Studio.NET

– A large, complex visual environment– Used to program in C#, Visual BASIC.NET,

Jscript, J#, or C++