2012年4月23日星期一

2.2 程序设计语言的演变简史

2.2 程序设计语言的演变简史


http://book.51cto.com 2010-07-06 09:30 王东青 清华大学出版社 我要评论(0)



2.2 程序设计语言的演变简史
最早的程序设计语言是机器语言,出现在20世纪50年代初。机器语言(machine language)也称为机器代码指令(machine code instruction)。直接用二进制的机器代码指令编写的、由处理器执行的程序就是机器语言程序。这是早期的程序设计语言,虽然计算机可以直接执行这种语言编写的程序,而且效率高、速度快,但是这种程序的可读性较差、难以记忆、与计算机处理器硬件紧密相关导致可移植性差。第一个商用计算机UNIVAC就使用了机器语言编程。有人把这种语言称为第一代语言(first generation language,1GL)。
机器语言很快被称为第二代语言(2GL)的汇编语言所代替。汇编语言(assembly language)是指用符号代替数字机器代码指令和其他常量进行编程的程序设计语言。汇编语言通常由计算机硬件制造商定义,使用的符号是有助于程序设计人员记忆的机器代码的缩写。被称为汇编程序的实用工具把汇编语言符号翻译成目标计算机的机器指令代码。这种语言依然是低级程序设计语言,因为一条汇编语言编写的语句只能翻译成一条机器指令代码。
当一条程序语句能够翻译成多条机器指令代码时,这种语言就称为高级程序设计语言。例如FORTRAN、COBOL、BASIC等都是高级程序设计语言。
第三代语言(3GL)是从2GL精炼而来的。2GL侧重于改进语言的逻辑结构,3GL主要是提高了语言的用户友好性。许多常见的语言都是3GL,例如FORTRAN、COBOL、BASIC、C、C++、Visual Basic、Java、C#等,都是典型的3GL。下面,介绍一下这些典型语言的演变过程及其特点。
1953年,IBM的John Backus领导一个开发团队开始开发FORTRAN语言。1957年4月,第一个FORTRAN版本正式发布。这是一个优化的编译器,也是一个高级程序设计语言。FORTRAN是公式翻译系统(formula translating system)的缩写。1966年FORTRAN语言被美国标准协会纳入标准,称为FORTRAN 66。与FORTRAN 66相比,1977年发布的FORTRAN 77语言有了许多重要的改变,特别是开始支持字符数据。1990年发布的Fortran 90语言增加了模块化编程并具备对象编程的特点。在发布的标准规范中,名称中的部分大写字母改成了小写字母。完全具备面向对象编程的版本是2003年发布的Fortran 2003,该版本与C语言具有互操作性。Fortran 2008语言在并行编程方面得到了增强。IBM开发的FORTRAN语言最早主要用于科学计算,后来逐渐应用在天气预报、有限元分析、流体力学、计算物理、计算化学等高性能计算领域。
Grace Hopper于1959年提出了COBOL语言的第一个规范。COBOL是通用商业语言(common business-oriented language)的简称,主要用于商业、金融、行政等行业领域。1968年,COBOL语言被纳入ANSI标准。2002年,COBOL语言被ISO接纳为标准。COBOL-2002包括了许多面向对象语言的特征,例如,支持本地语言、用户定义的函数、指针、在.NET和Java环境中执行等,并且还可以生成和分析XML语言。
1964年,美国达特茅斯学院的两位教授John Kemeny和Thomas Kurtz在教授计算机课程的时候,针对非计算机专业的学生的特点,提出了BASIC(beginner's all-purpose symbolic instruction code,针对初学者的一般用途的符号指令代码)语言。该语言采用了解释计算方式,具有简单易学的特点。在20世纪70、80年代出现了大量的BASIC语言变种,例如微软公司1981年发布的IBM BASICA、Borland公司1985年发布的Turbo BASIC等。微软公司1991年推出的Visual Basic语言,除了具有图形化用户界面、事件驱动编程、集成的开发环境等特点之外,继承了BASIC语言的许多特点。
1972年,AT&T贝尔实验室的Dennis Trichie在开发Unix操作系统的过程中,提出了C程序设计语言。之所以称为C语言,是因为其来自早期的B(BCPL)语言。1978年,Brian Kernighan和Dennis Ritchie出版了《C程序设计语言》一书,该书详细描述了C语言的规范。1983年,C语言成为ANSI C。1990年,ANSI C被纳为ISO标准。1999年,被称为C99的ISO/IEC 9899:1999标准引入了一些新的功能,包括内联函数、long long int数据类型、可变长度的数组、单行注释等。虽然C语言来自于操作系统的实现,但是现在也被广泛应用于开发各种可移植的应用程序,并且对后来的许多语言有重大的影响。例如,C++、Java、C#等语言都受到了C语言的显著影响。
1979年,在贝尔实验室工作的、29岁的Bjarne Stroustrup在写剑桥大学的博士论文时,对C语言进行了研究,并尝试在C语言中增加类以便增强C语言的功能。他的这项研究结果产生了C with Classes语言。1983年,C with Classes语言的名称改为C++语言,其中++表示增量运算符。与C语言相比,C++语言中增加了虚拟函数、函数名和运算符重载、引用、用户控制的内存控制等。1985年,《C++程序设计语言》一书出版。1989年,多继承性、抽象类、静态成员函数、常量成员函数、保护成员等功能被增加到C++语言中。1990年,C++中又增加了模板、异常处理、命名空间等功能。1998年,C++语言被纳入ISO/IEC标准体系中。2003年,新修订后的标准是ISO/IEC 14882:2003。目前,C++是一种非常流行的程序设计语言,在系统软件、应用软件、嵌入式软件、高性能服务器等诸多领域都有广泛的应用。
Visual Basic是微软公司于1991年发布的、基于COM模型的、具有集成开发环境的第三代事件驱动式程序设计语言。在Visual Basic语言中,可以使用拖拉技术创建表单,表单上可以放置控件,控件有属性和事件处理程序。使用Visual Basic语言可以创建可执行程序、ActiveX控件、DLL文件等。1998年,微软发布的Visual Basic 6是该软件的最终版本,其后续版本被命名为Visual Basic .NET语言。2002年发布的Visual Basic .NET是一种基于微软.NET框架的面向对象程序设计语言,该版本的语言与VB6开发的应用程序之间没有兼容性。2007年发布的Visual Basic 2008(也称为VB9)是与Microsoft .NET Framework 3.5对应的,增加了许多新的功能,例如条件运算符、匿名类型、LINQ支持、XML字符支持等。
Java语言是1995年由Sun Microsystems公司发布的,是James Gosling领导的开发小组开发的程序设计语言。最初的名称是Oak,后来命名为Java。Java源程序经过编译生成可以运行在Java虚拟机上的字节码,从而实现Write Once,Run Anywhere的跨平台运行目标。Java语言的主要特点包括:纯粹的面向对象语言、跨平台、编译-解释执行、支持多线程、支持分布式应用等。Java也是一种源代码开放软件。目前,Java语言是一种非常流行的程序设计语言,在许多领域都有广泛的应用。据TIOBE公司统计,Java语言在程序设计语言排行榜中持续多年名列榜首。
C#语言是微软公司于2001年发布的、具有面向对象功能的、运行于.NET Framework之上的程序设计语言。C#语言的主要开发人员是丹麦软件工程师Anders Hejlsberg。C#继承了C和C++强大功能的同时,去掉了一些它们的复杂特性,例如没有宏和模板,不允许多重继承等。C#与Java有许多类似的地方,例如,与Java几乎同样的语法和编译成中间代码再运行的过程。但是,C#又与Java语言有显著的不同,它借鉴了Pascal、Delphi等语言的特点,是.NET程序开发的首选语言工具。2001年,ECMA接受C#语言为其标准,并发布了ECMA-334C#语言标准规范。2003年,C#语言也成为ISO/IEC 23270标准。
第四代语言(4GL)是从3GL演变而来的,具有更高抽象级别程序设计语言或程序设计环境。虽然说3GL是更加自然的、块结构的语言,但是3GL的开发方法依然比较缓慢、容易出错。与3GL相比,4GL是针对特定目的的、面向问题和系统工程的程序设计语言。目前,4GL可以分为一般作用的语言(例如Clipper、Foxpro、PowerBuilder等)、数据库查询语言(例如SQL语言)、报表生成语言(例如Metafont、Oracle Report、NATURAL等语言)、数据操纵和统计分析语言(例如MATLAB、SAS、SPSS、Stata等语言)、Web开发语言(例如ColdFusion)等。
目前,有关第五代语言(5GL)的话题正处于讨论中。一般地认为,5GL关注的是约束条件和逻辑,而不是如何去实现算法。例如,对于一个给定的问题,5GL侧重于写出解决这种问题需要的条件和约束,而不是关注如何编写算法来解决这种问题。5GL主要用于解决人工智能领域中的问题。



Appendix H: 4GL or 5GL 4GLs are typically used to meet special needs of data processing, with such applications as databases, spreadsheets, and program generators for use by non-expert programmers [Ghezzi 87]. 4GLs typically have properties such as [Appleby 91]:
  • database structures and programming
  • centralized data dictionary containing information about system components
  • visual programming, such as using a mouse with icons
  • graded-skill user interface allowing novices as well as database experts to use the programs
  • interactive, integrated, multifunction programming environment
The intent of 4GLs is to "make languages easy to use so that end users can solve their own problems and put computers to work" [Martin 86]. However, a 4GL must be selected to fit the particular application, unlike 3GLs, which tend to be more general purpose. 4GLs are essentially non-procedural, whereas 3GLs tend to be procedural, but there is no standard definition. The term 4GL is actually very imprecise, and it is used for marketing reasons to describe many modern application development tools. [Appleby 91] [DoD 87] [Glass 91] [Martin 86] [Misra 88] [Verner 88] [Wojtkowski 90]
A 5GL is essentially a 4GL that uses a knowledge-based system [ANSI/IEEE 90], although some such systems are also called 4GLs. A 5GL tends to be a more complete development environment than a 4GL, and its concept is for all code to be automatically generated. Then a system is maintained by modifying the 5GL statements, rather than manually changing the generated code. [Connors 94]
Language Criteria
It is impossible to assess every possible 4GL or 5GL of interest because these language applications are numerous, and more are appearing all the time. It is important to note that these languages vary widely in capabilities and intended purpose. Some newer ones, such as Visual Basic and Powerbuilder, are particularly powerful with respect to ease of programming and prototyping capabilities. Others, such as SQL and Oracle, have been around for a while but continue to provide powerful capabilities for interfacing with databases. All languages in this category also share many concepts. A specific language should be examined in terms of how its specific purpose matches the current need, and its particular characteristics should be assessed with respect to the language criteria. The general category of 4GL and 5GL languages is considered in this appendix. The assessments can be used to guide the assessment of a specific language. Hence, the following assesses the category of 4GLs and 5GLs with respect to the language criteria presented in the Criteria for a Good Language section in the main document:

  1. Its definition should be independent of any particular hardware or operating system. A 4GL or 5GL is defined at a very high level, and, therefore, it is independent of any particular platform.

  2. Its definition should be standardized, and compiler implementations should comply with this standard. Since 4GLs and 5GLs are more like applications than languages in the way they are used, only a few have been concerned with standardization. Of these, SQL is probably the most popular because it is widely used as a database query language. The SQL ANSI and ISO standard provides a baseline language, and implementations are likely to provide additional language features as well [
  1. Appleby 91].

  2. It should support software engineering technology, discouraging or prohibiting poor practices, and promoting or supporting maintenance activities. Since a 4GL or 5GL is used more like an application than a language, specific support for engineering good software within the 4GL or 5GL is not usually a concern. The emphasis is on making the development system easy to use. However, the method of creating an application from one of these systems often makes good use of certain aspects of software engineering technology. For example, providing a mechanism for automatically generating code for an application makes good use of such software engineering concepts as abstraction and maintainability (assuming that changes made to the code are also made using the 4GL or 5GL). Also, some types of poor practices are discouraged or prohibited because of the mechanisms provided for the user to interact with the system.

  3. It should effectively support the application domain(s) of interest. A 4GL or 5GL is specific to a particular application domain, and it should only be used within that domain. To attempt to use it outside its intended domain is to negate its potential benefits.

  4. It should support the required level of system reliability and safety. Reliability is not a primary concern for these development systems, and the actual reliability of a system generated by a 4GL or 5GL will vary with the particular language used. Safety-critical systems, those concerned with putting human lives in jeopardy, are not supported by current 4GLs or 5GLs.

  5. Its compiler implementations should be commensurate with the current state of technology. It makes more sense here to discuss the tool set comprising the 4GL or 5GL, because this tool set transforms the program into a form understandable by the computer, much as a compiler does for a 3GL. With such a wide variety of products available in this category, as well as the increasing interest in this form of creating software, 4GL and 5GL implementations continue to be competitive by taking full advantage of current technology. With this technology changing so rapidly, versions of products more than a year old will not use the current state of the technology.

  6. Appropriate software engineering-based supporting tools and environments should be available. A 4GL or 5GL tends to contain its own development environment. Most 4GLs do not support a complete software engineering process, and, in this respect, their usefulness is usually limited to systems that are small, or possibly medium, in size and complexity [Misra 88] [Wojtkowski 90]. The 5GL concept is to provide a more complete support environment. However, these systems have not existed long enough for information on their effectiveness to be studied. It is also likely that the amount of software engineering support provided by different products will vary widely.
Language Characteristics

In this section, 4GLs and 5GLs are rated with respect to the language characteristics used in
Table 2 in the main document [Appleby 91] [DoD 87] [Glass 91] [Martin 86] [Misra 88] [Verner 88] [Wojtkowski 90]. The given ratings are for this category of languages, rather than a specific language. Hence, a given rating is intended to be typical of a 4GL or 5GL, but a rating may not be representative of every product. The ratings range from 0 to 10, where 0 means the language provides no support for the characteristic, and 10 means it provides extensive support. The ratings given below are those provided in Table 2. The reader must bear in mind that the support for a good characteristic in a language does not necessarily mean that it is always used, or used appropriately. Unskilled programmers can write bad code in any language, but a good language facilitates the production of good code by skilled programmers.
Clarity of source code – the extent to which inherent language features support source code that is readable and understandable and that clearly reflects the underlying logical structure of the program. For this characteristic, the source code consists of the commands used by the programmer, and this varies greatly with different 4GLs and 5GLs. Many use graphical interfaces or menus that require very little typing. The higher the language level, the better the code clarity tends to be because of the nature of the commands used. However, to the extent that the commands are text-based, they tend to be full of abbreviations and not completely descriptive. This rating will vary with different products, with the given rating considered typical. Rating: 5
Complexity management (architecture support) – the extent to which inherent language features support the management of system complexity, in terms of addressing issues of data, algorithm, interface, and architectural complexity.
A 4GL or 5GL tends to target a relatively small application, and complexity management is not one of the development considerations. Complexity is usually managed only through the use of abstraction. Rating: 2
Concurrency support – the extent to which inherent language features support the construction of code with multiple threads of control (also known as parallel processing).
Support for concurrency is not usually represented in 4GLs or 5GLs. Rating: 0
Distributed system support – the extent to which inherent language features support the construction of code to be distributed across multiple platforms on a network.
In general, 4GLs and 5GLs provide no support for distributed systems. Rating: 0
Maintainability – the extent to which inherent language features support the construction of code that can be readily modified to satisfy new requirements or to correct deficiencies.
If the 4GL or 5GL is used as intended, maintenance is performed on the high-level commands provided by the development system, rather than on the low-level code intended to be understood by the computer. To the extent that this concept is used, the maintainability is generally good. Understanding the program from the high-level commands facilitates maintainability, and small changes will usually not impact more than a small number of the high-level commands. However, the low-level code tends to be very difficult to understand, and making changes at that level is not easy. Since most current 4GL development systems cannot automatically generate all of the necessary code for many applications, and the ability of a 5GL to generate all necessary code is still in doubt, maintenance must consider working with some low-level code. Rating: 5
Mixed language support – the extent to which inherent language features support interfacing to other languages.
4GL and 5GL systems are not usually concerned with interfacing with other languages, although other languages are often concerned with interfacing with a 4GL such as SQL. When procedural commands are needed, a language is usually provided for that purpose by the 4GL or 5GL, rather than relying on a conventional 3GL. This is an inherent weakness because the procedural language provided is typically not as rich or expressive as a conventional 3GL [Misra 88]. Rating: 0
Object-oriented programming support – the extent to which inherent language features support the construction of object-oriented code.
Although a 4GL or 5GL uses high-level commands, and it is possible for these to be object-oriented in nature, they usually are not. Constructing object-oriented code is rarely an issue. Rating: 0
Portability – the extent to which inherent language features support the transfer of a program from one hardware and/or software platform to another.
Since a 4GL or 5GL is used more like an application than a language, portability is not a major goal. SQL is portable to a certain extent because it is standardized (an exception rather than a rule in a 4GL or 5GL), but since most applications use non-standard features, its portability is also limited. Rating: 1
Real-time support – the extent to which inherent language features support the construction of real-time systems.
Real-time systems are not usually a concern of 4GLs or 5GLs, although there are a few exceptions for which the given rating should be changed accordingly. Rating: 0
Reliability – the extent to which inherent language features support the construction of components that can be expected to perform their intended functions in a satisfactory manner throughout the expected lifetime of the product.
Reliability is not usually a primary concern for a 4GL or 5GL application. Rating: 3
Reusability – the extent to which inherent language features support the adaptation of code for use in another application.
Since a 4GL or 5GL is used more like an application than a language, reusability is not usually a goal. Only a widely-used and standardized language, such as SQL, could be reasonably considered for reuse. However, SQL does not have inherent characteristics, such as encapsulation, which lends itself to reusability. Rating: 1
Safety – the extent to which inherent language features support the construction of safety-critical systems, yielding systems that are fault-tolerant, fail-safe, or robust in the face of systemic failures.
Safety systems, those concerned with putting human lives in jeopardy, are not supported by current 4GLs or 5GLs. Rating: 0
Standardization – the extent to which the language definition has been formally standardized (by recognized bodies such as ANSI and ISO) and the extent to which it can be reasonably expected that this standard will be followed in a language translator.
Since 4GLs and 5GLs are more like applications than languages in the way they are used, only a few have been concerned with standardization. Of these, SQL is probably the most popular because it is widely used as a database query language. The SQL ANSI and ISO standard provides a baseline language, and implementations are likely to provide additional language features as well. Rating: 1
Support for modern engineering methods – the extent to which inherent language features support the expression of source code that enforces good software engineering principles.
Since a 4GL or 5GL is used more like an application than a language, specific support for engineering good software is not usually a concern. The emphasis is on making the development system easy to use. However, some types of poor practices are discouraged or prohibited because of the high-level mechanisms provided for the user to interact with the system. Rating: 3



1. 程序和编程语言
上一页 第 1 章 程序的基本概念 下一页



程序(Program)告诉计算机应如何完成一个计算任务,这里的计算可以是数学运算,比如解方程,也可以是符号运算,比如查找和替换文档中的某个单词。从根本上说,计算机是由数字电路组成的运算机器,只能对数字做运算,程序之所以能做符号运算,是因为符号在计算机内部也是用数字表示的。此外,程序还可以处理声音和图像,声音和图像在计算机内部必然也是用数字表示的,这些数字经过专门的硬件设备转换成人可以听到、看到的声音和图像。
程序由一系列指令(Instruction)组成,指令是指示计算机做某种运算的命令,通常包括以下几类:
输入(Input)
对于程序来说,有上面这几类指令就足够了。你曾用过的任何一个程序,不管它有多么复杂,都是由这几类指令组成的。程序是那么的复杂,而编写程序可以用的指令却只有这么简单的几种,这中间巨大的落差就要由程序员去填了,所以编写程序理应是一件相当复杂的工作。编写程序可以说就是这样一个过程:把复杂的任务分解成子任务,把子任务再分解成更简单的任务,层层分解,直到最后简单得可以用以上指令来完成。
编程语言(Programming Language)
分为低级语言(Low-level Language)和高级语言(High-level Language)。机器语言(Machine Language)和汇编语言(Assembly Language)属于低级语言,直接用计算机指令编写程序。而C、C++、Java、Python等属于高级语言,用语句(Statement)编写程序,语句是计算机指令的抽象表示。举个例子,同样一个语句用C语言、汇编语言和机器语言分别表示如下:

计算机只能对数字做运算,符号、声音、图像在计算机内部都要用数字表示,指令也不例外,上表中的机器语言完全由十六进制数字组成。最早的程序员都是直接用机器语言编程,但是很麻烦,需要查大量的表格来确定每个数字表示什么意思,编写出来的程序很不直观,而且容易出错,于是有了汇编语言,把机器语言中一组一组的数字用助记符(Mnemonic)
表示,直接用这些助记符写出汇编程序,然后让汇编器(Assembler)去查表把助记符替换成数字,也就把汇编语言翻译成了机器语言。从上面的例子可以看出,汇编语言和机器语言的指令是一一对应的,汇编语言有三条指令,机器语言也有三条指令,汇编器就是做一个简单的替换工作,例如在第一条指令中,把movl ?,%eax这种格式的指令替换成机器码a1 ?,?表示一个地址,在汇编指令中是0x804a01c,转换成机器码之后是1c a0 04 08(这是指令中的十六进制数的小端表示,小端表示将在第 5.1 节 “目标文件”介绍)。
从上面的例子还可以看出,C语言的语句和低级语言的指令之间不是简单的一一对应关系,一条a=b+1;语句要翻译成三条汇编或机器指令,这个过程称为编译(Compile),由编译器(Compiler)来完成,显然编译器的功能比汇编器要复杂得多。用C语言编写的程序必须经过编译转成机器指令才能被计算机执行,编译需要花一些时间,这是用高级语言编程的一个缺点,然而更多的是优点。首先,用C语言编程更容易,写出来的代码更紧凑,可读性更强,出了错也更容易改正。其次,C语言是可移植的(Portable)或者称为平台无关的(Platform Independent)
平台这个词有很多种解释,可以指计算机体系结构(Architecture),也可以指操作系统(Operating System),也可以指开发平台(编译器、链接器等)。不同的计算机体系结构有不同的指令集(Instruction Set),可以识别的机器指令格式是不同的,直接用某种体系结构的汇编或机器指令写出来的程序只能在这种体系结构的计算机上运行,然而各种体系结构的计算机都有各自的C编译器,可以把C程序编译成各种不同体系结构的机器指令,这意味着用C语言写的程序只需稍加修改甚至不用修改就可以在各种不同的计算机上编译运行。各种高级语言都具有C语言的这些优点,所以绝大部分程序是用高级语言编写的,只有和硬件关系密切的少数程序(例如驱动程序)才会用到低级语言。还要注意一点,即使在相同的体系结构和操作系统下,用不同的C编译器(或者同一个C编译器的不同版本)编译同一个程序得到的结果也有可能不同,C语言有些语法特性在C标准中并没有明确规定,各编译器有不同的实现,编译出来的指令的行为特性也会不同,应该尽量避免使用不可移植的语法特性。
总结一下编译执行的过程,首先你用文本编辑器写一个C程序,然后保存成一个文件,例如program.c(通常C程序的文件名后缀是.c),这称为源代码(Source Code)或源文件,然后运行编译器对它进行编译,编译的过程并不执行程序,而是把源代码全部翻译成机器指令,再加上一些描述信息,生成一个新的文件,例如a.out,这称为可执行文件,可执行文件可以被操作系统加载运行,计算机执行该文件中由编译器生成的指令,如下图所示:

有些高级语言以解释(Interpret)
的方式执行,解释执行过程和C语言的编译执行过程很不一样。例如编写一个Shell脚本script.sh,内容如下:
#! /bin/sh
VAR=1
VAR=$(($VAR+1))
echo $VAR
定义Shell变量VAR的初始值是1,然后自增1,然后打印VAR的值。用Shell程序/bin/sh解释执行这个脚本,结果如下:
$ /bin/sh script.sh
2
这里的/bin/sh称为解释器(Interpreter)
,它把脚本中的每一行当作一条命令解释执行,而不需要先生成包含机器指令的可执行文件再执行。如果把脚本中的这三行当作三条命令直接敲到Shell提示符下,也能得到同样的结果:
$ VAR=1
$ VAR=$(($VAR+1))
$ echo $VAR
2

编程语言仍在发展演化。以上介绍的机器语言称为第一代语言(1GL,1st Generation Programming Language)
,汇编语言称为第二代语言(2GL,2nd Generation Programming Language),C、C++、Java、Python等可以称为第三代语言(3GL,3rd Generation Programming Language)。目前已经有了4GL(4th Generation Programming Language)和5GL(5th Generation Programming Language)的概念。3GL的编程语言虽然是用语句编程而不直接用指令编程,但语句也分为输入、输出、基本运算、测试分支和循环等几种,和指令有直接的对应关系。而4GL以后的编程语言更多是描述要做什么(Declarative)而不描述具体一步一步怎么做(Imperative),具体一步一步怎么做完全由编译器或解释器决定,例如SQL语言(SQL,Structured Query Language,结构化查询语言)就是这样的例子。

1、解释执行的语言相比编译执行的语言有什么优缺点?
这是我们的第一个思考题。本书的思考题通常要求读者系统地总结当前小节的知识,结合以前的知识,并经过一定的推理,然后作答。本书强调的是基本概念,读者应该抓住概念的定义和概念之间的关系来总结,比如本节介绍了很多概念:程序语句指令组成,计算机只能执行低级语言中的指令(汇编语言的指令要先转成机器码才能执行),高级语言要执行就必须先翻译成低级语言,翻译的方法有两种--编译解释,虽然有这样的不便,但高级语言有一个好处是平台无关性。什么是平台?一种平台,就是一种体系结构,就是一种指令集,就是一种机器语言,这些都可看作是一一对应的,上文并没有用“一一对应”这个词,但读者应该能推理出这个结论,而高级语言和它们不是一一对应的,因此高级语言是平台无关的,概念之间像这样的数量对应关系尤其重要。那么编译和解释的过程有哪些不同?主要的不同在于什么时候翻译和什么时候执行。
现在回答这个思考题,根据编译和解释的不同原理,你能否在执行效率和平台无关性等方面做一下比较?

没有评论:

发表评论