(计算机英语 第三单元 计算机语言与编程).doc_第1页
(计算机英语 第三单元 计算机语言与编程).doc_第2页
(计算机英语 第三单元 计算机语言与编程).doc_第3页
(计算机英语 第三单元 计算机语言与编程).doc_第4页
(计算机英语 第三单元 计算机语言与编程).doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Unit 3 Computer Language and Programming第三单元: 计算机语言与编程 Section A Programming Language课文A: 编程语言 . Introduction一、引言Programming languages, in computer science, are the artificial languages used to write a sequence of instructions (a computer program) that can be run by a computer.在计算机科学中,编程语言是用于编写可由计算机运行的一系列指令(计算机程序)的人工语言。 Similar to natural languages, such as English, programming languages have a vocabulary, grammar, and syntax.与英语等自然语言相类似,编程语言有词汇、语法和句法。 However, natural languages are not suited for programming computers because they are ambiguous, meaning that their vocabulary and grammatical structure may be interpreted in multiple ways.然而,自然语言不适合为计算机编程,因为它们会引起歧义,也就是说它们的词汇和语法结构可能被用多种方式进行解释。 The languages used to program computers must have simple logical structures, and the rules for their grammar, spelling, and punctuation must be precise.用于计算机编程的语言必须有简单的逻辑结构,它们的语法、拼写和标点符号规则必须精确。 Programming languages vary greatly in their sophistication and in their degree of versatility.编程语言在复杂性和通用程度上差异很大。 Some programming languages are written to address a particular kind of computing problem or for use on a particular model of computer system.一些编程语言是为了处理特定类型的计算问题或为了用于特定型号的计算机系统而编写的。 For instance, programming languages such as FORTRAN and COBOL were written to solve certain general types of programming problemsFORTRAN for scientific applications, and COBOL for business applications.例如,FORTRAN和COBOL等编程语言是为解决某些普遍的编程问题类型而编写的FORTRAN是为了科学领域的应用,而COBOL是为了商业领域的应用。 Although these languages were designed to address specific categories of computer problems, they are highly portable, meaning that they may be used to program many types of computers.尽管这些语言旨在处理特定类型的计算机问题,但它们具有很高的可移植性,也就是说它们可以用来为多种类型的计算机编程。 Other languages, such as machine languages, are designed to be used by one specific model of computer system, or even by one specific computer in certain research applications.其他的语言,如机器语言,是为一种特定型号的计算机系统,甚至是一台特定的计算机,在某些研究领域使用而编写的。 The most commonly used programming languages are highly portable and can be used to effectively solve diverse types of computing problems.最常用的编程语言具有很高的可移植性,可以用于有效地解决不同类型的计算问题。 Languages like C, PASCAL, and BASIC fall into this category.像C、PASCAL和BASIC这样的语言就属于这一范畴。 . Language Types二、语言类型Programming languages can be classified as either low-level languages or high-level languages.编程语言可分为低级语言和高级语言。 Low-level programming languages, or machine languages, are the most basic type of programming languages and can be understood directly by a computer.低级编程语言或机器语言,是编程语言中最基础的类型,可以被计算机直接理解。 Machine languages differ depending on the manufacturer and model of computer.机器语言视计算机制造商与型号不同而有所区别。 High-level languages are programming languages that must first be translated into a machine language before they can be understood and processed by a computer.高级语言是必须首先翻译成机器语言计算机才能理解和处理的编程语言。 Examples of high-level languages are C, C+, PASCAL, and FORTRAN.C、C+、PASCAL和FORTRAN都是高级语言的例子。 Assembly languages are intermediate languages that are very close to machine languages and do not have the level of linguistic sophistication exhibited by other high-level languages, but must still be translated into machine language.汇编语言是中级语言,非常接近于机器语言,没有其他高级语言所表现出的语言复杂程度,但仍然得翻译成机器语言。 1. Machine Languages1、机器语言In machine languages, instructions are written as sequences of 1s and 0s, called bits, that a computer can understand directly.在机器语言中,指令被写成计算机能够直接理解的1和0(称作位)序列。 An instruction in machine language generally tells the computer four things:一条机器语言指令一般告诉计算机4件事: (1) where to find one or two numbers or simple pieces of data in the main computer memory (Random Access Memory, or RAM),(1)到计算机主存(随机存储器)的什么位置去找一两个数字或简单的数据片; (2) a simple operation to perform, such as adding the two numbers together,(2)要执行的简单操作,如将两个数字相加; (3) where in the main memory to put the result of this simple operation, and(3)在主存的什么位置存放该简单操作的结果; (4) where to find the next instruction to perform.(4)到什么位置去找下一条要执行的指令。 While all executable programs are eventually read by the computer in machine language, they are not all programmed in machine language.尽管所有的可执行程序最终都是以机器语言的形式被计算机读入的,但它们并非都是用机器语言编写的。 It is extremely difficult to program directly in machine language because the instructions are sequences of 1s and 0s.直接用机器语言编程极端困难,因为指令是0和1的序列。 A typical instruction in a machine language might read 10010 1100 1011 and mean add the contents of storage register A to the contents of storage register B.一条典型的机器语言指令可能写成100101100 1011,意思是把存储寄存器A的内容加到存储寄存器B的内容中。 2. High-Level Languages2、高级语言High-level languages are relatively sophisticated sets of statements utilizing words and syntax from human language.高级语言是相对复杂的一系列语句,它们使用来自人类语言的词汇和句法。 They are more similar to normal human languages than assembly or machine languages and are therefore easier to use for writing complicated programs.高级语言比汇编语言或机器语言类似于正常的人类语言,因此用高级语言来编写复杂的程序比较容易。 These programming languages allow larger and more complicated programs to be developed faster.这些编程语言可以更快地开发更大和更复杂的程序。 However, high-level languages must be translated into machine language by another program called a compiler before a computer can understand them.然而,高级语言必须由称为编译器的另外一种程序翻译成机器语言,计算机才能理解它们。 For this reason, programs written in a high-level language may take longer to execute and use up more memory than programs written in an assembly language.因为这个原因,与用汇编语言编写的程序相比较,用高级语言编写的程序可能运行时间长,占用内存多。 3. Assembly Languages3、汇编语言Computer programmers use assembly languages to make machine-language programs easier to write.计算机程序员通过使用汇编语言,使机器语言程序比较容易编写。 In an assembly language, each statement corresponds roughly to one machine language instruction.在汇编语言中,每个语句大致对应于一条机器语言指令。 An assembly language statement is composed with the aid of easy to remember commands.汇编语言的语句是借助易于记忆的命令编写的。 The command to add the contents of the storage register A to the contents of storage register B might be written ADD B, A in a typical assembly language statement.在一个典型的汇编语言语句中,把存储寄存器A的内容加到存储寄存器B的内容中这一命令,可能写成ADD B, A。 Assembly languages share certain features with machine languages.汇编语言与机器语言具有某些共同的特征。 For instance, it is possible to manipulate specific bits in both assembly and machine languages.例如,对特定的位进行操控,用汇编语言和机器语言都是可行的。 Programmers use assembly languages when it is important to minimize the time it takes to run a program, because the translation from assembly language to machine language is relatively simple.当尽量减少程序的运行时间很重要时,程序员就使用汇编语言,因为从汇编语言到机器语言的翻译相对简单。 Assembly languages are also used when some part of the computer has to be controlled directly, such as individual dots on a monitor or the flow of individual characters to a printer.汇编语言也用于计算机的某个部分必须被直接控制的情况,如监视器上的单个点或者单个字符向打印机的流动。 .Classification of High-level languages三、高级语言的分类 High-level languages are commonly classified as procedure-oriented, functional, object-oriented, or logic languages.高级语言通常分为面向过程语言、函数式语言、面向对象语言或逻辑语言。 The most common high-level languages today are procedure-oriented languages.当今最常见的高级语言是面向过程语言。 In these languages, one or more related blocks of statements that perform some complete function are grouped together into a program module, or procedure, and given a name such as “procedure A.”在这种语言中,执行某个完整功能的一个或多个相关的语句块组成一个程序模块或过程,而且被给予诸如“过程A”一类名称。 If the same sequence of operations is needed elsewhere in the program, a simple statement can be used to refer back to the procedure.如果在程序的其他地方需要同样的操作序列,可以使用一个简单的语句调回这个过程。 In essence, a procedure is just a mini-program.实质上,一个过程就是一个小型程序。 A large program can be constructed by grouping together procedures that perform different tasks.一个大型程序可以通过将执行不同任务的过程组合在一起而构成。 Procedural languages allow programs to be shorter and easier for the computer to read, but they require the programmer to design each procedure to be general enough to be used in different situations.过程语言使程序变得比较短,而且比较容易被计算机读取,但要求程序员将每个过程都设计得足够通用,能用于不同的情况。 Functional languages treat procedures like mathematical functions and allow them to be processed like any other data in a program.函数式语言像对待数学函数一样对待过程,并允许像处理程序中的任何其他数据一样处理它们。 This allows a much higher and more rigorous level of program construction.这就使程序构造在更高、更严密的水平上得以实现。 Functional languages also allow variablessymbols for data that can be specified and changed by the user as the program is runningto be given values only once.函数式语言也允许变量在程序运行过程中可以被用户指定和更改的数据符号只被赋值一次。 This simplifies programming by reducing the need to be concerned with the exact order of statement execution, since a variable does not have to be redeclared, or restated, each time it is used in a program statement.这样,通过减少对语句执行的确切顺序给予关注的必要性,就简化了编程,因为一个变量没有必要每次在一个程序语句中用到,都重新声明或重新说明。 Many of the ideas from functional languages have become key parts of many modern procedural languages.来自函数式语言的许多思想已经成为许多现代过程语言的关键部分。 Object-oriented languages are outgrowths of functional languages.面向对象语言是函数式语言的发展结果。 In object-oriented languages, the code used to write the program and the data processed by the program are grouped together into units called objects.在面向对象语言中,用来编写程序的代码和由程序处理的数据,组合成叫做对象的单元。 Objects are further grouped into classes, which define the attributes objects must have.对象进一步组合成类,而类则定义对象必须具有的属性。 A simple example of a class is the class Book.类的一个简单例子就是书这个类。 Objects within this class might be Novel and Short Story.这个类中的对象可能是小说和短篇小说。 Objects also have certain functions associated with them, called methods.对象还有某些与其相关的功能,称为方法。 The computer accesses an object through the use of one of the objects methods.计算机通过使用一个对象的某种方法来访问该对象。 The method performs some action to the data in the object and returns this value to the computer.方法对对象中的数据执行某种操作,然后将值返回给计算机。 Classes of objects can also be further grouped into hierarchies, in which objects of one class can inherit methods from another class.对象的类也可进一步组合成层,而在层中一个类的对象可继承另一个类的方法。 The structure provided in object-oriented languages makes them very useful for complicated programming tasks.面向对象语言提供的这种结构,使该语言对于复杂的编程任务非常有用。 Logic languages use logic as their mathematical base.逻辑语言将逻辑用作其数学基础。 A logic program consists of sets of facts and if-then rules, which specify how one set of facts may be deduced from others, for example:逻辑程序由事实组和“如果则”规则构成,“如果则”规则具体说明一组事实如何可以从其他事实组中推断出来,例如: If the statement X is true, then the statement Y is false.如果X语句为真,则Y语句为假。 In the execution of such a program, an input statement can be logically deduced from other statements in the program.在这样一个程序的执行过程中,一条输入语句可以按照逻辑从程序中的其他语句推断出来。 Many artificial intelligence programs are written in such languages.许多人工智能程序使用这种语言编写。 . Language structure and components四、语言结构与成分Programming languages use specific types of statements, or instructions, to provide functional structure to the program.编程语言使用特定类型的语句或指令,来给程序提供功能结构。 A statement in a program is a basic sentence that expresses a simple ideaits purpose is to give the computer a basic instruction.程序中的一个语句是表达一个简单想法的基本句子它的目的是给计算机一条基本指令。 Statements define the types of data allowed, how data are to be manipulated, and the ways that procedures and functions work.语句定义所允许的数据类型、数据如何处理以及过程和函数的工作方式。 Programmers use statements to manipulate common components of programming languages, such as variables and macros (mini-programs within a program).程序员使用语句来操控编程语言的常见成分,如变量和宏(程序中的小程序段)。 Statements known as data declarations give names and properties to elements of a program called variables.数据声明语句给称为变量的那些程序元素以名称和属性。 Variables can be assigned different values within the program.变量在程序中可以赋予不同的值。 The properties (that) variables can have are called types, and they include such things as what possible values might be saved in the variables, how much numerical accuracy is to be used in the values, and how one variable may represent a collection of simpler values in an organized fashion, such as a table or array.变量可以具有的属性称为类型,它们包括: 变量中能保存哪些可能的值; 这些值中使用何种程度的数值精度; 以及一个变量可以如何以有组织结构的方式如以表或数组的形式表示一组比较简单的值。 In many programming languages, a key data type is a pointer.在许多编程语言中,一个关键的数据类型是指针。 Variables that are pointers do not themselves have values; instead, they have information that the computer can use to locate some other variablethat is, they point to another variable.指针变量本身没有值,而是含有计算机可以用来查找某个其他变量的信息也就是说,它们指向另一个变量。 An expression is a piece of a statement that describes a series of computations to be performed on some of the programs variables, such as X+Y/Z, in which the variables are X, Y, and Z and the computations are addition and division.表达式是语句的一段,用于描述要对一些程序变量执行的一系列计算操作,如X+Y/Z,其中X、Y和Z为变量,加法和除法是计算操作。 An assignment statement assigns a variable a value derived from some expression, while conditional statements specify expressions to be tested and then used to select which other statements should be executed next.赋值语句给一个变量赋予得自某个表达式的值,而条件语句则指定要被测试、然后用于选择接下来应该执行的其他语句的表达式。 Procedure and function statements define certain blocks of code as procedures or functions that can then be returned to later in the program.过程和函数语句将某些代码块定义为以后可在程序中回调的过程或函数。 These statements also define the kinds of variables and parameters (that) the programmer can choose and the type of value that the code will return when an expression accesses the procedure or function.这些语句也定义程序员可选的变量和参数种类,以及当表达式访问过程或函数时代码所返回的值的类型。 Many programming languages also permit minitranslation programs called macros.许多编程语言也容许叫做宏的小翻译程序。 Macros translate segments of code that have been written in a language structure defined by the programmer into statements that the programming language understands.宏将那些用程序员定义的语言结构编写的代码段翻译成编程语言可以理解的语句。 . History五、历史Programming languages date back almost to the invention of the digital computer in the 1940s.编程语言几乎可以追溯到20世纪40年代数字计算

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论