英文文獻(xiàn)及翻譯:計算機(jī)程序_第1頁
英文文獻(xiàn)及翻譯:計算機(jī)程序_第2頁
英文文獻(xiàn)及翻譯:計算機(jī)程序_第3頁
英文文獻(xiàn)及翻譯:計算機(jī)程序_第4頁
英文文獻(xiàn)及翻譯:計算機(jī)程序_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、Computer Language and ProgrammingI. IntroductionProgramming 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

2、, 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 rul

3、es 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 particularkind of computing problem or for use on a particular model of computer system. F

4、or instance, programming languages such as FORTRAN and COBOL were written to solve certain general types of programming problems FORTRAN for scientificapplications, and COBOL for business applications. Although these languages were designed to address specific categories of computer problems, they a

5、re highly portable, meaning that they may be used to program many type s 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 l

6、anguages 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.II. Language TypesProgramming languages can be classified as either low-level languages or high-level languages. Low-levelprogramming lang

7、uages, 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 firstbe translated into a machine language

8、 before they can be understood and processed by a computer. Examples of high-level languages are C, C+, PASCAL, and FORTRAN. Assembly languages are intermediate languages that are very clo se to machine languages and do not have the level of linguistic sophistication exhibited by other high-level la

9、nguages, but must still be translated into machine language.1. Machine LanguagesIn machine languages, instructions are written as sequences of 1s and 0s, called bits, that a computer can understand directly. An instruction in machine language generally tells the computer four things: (1) where to fi

10、nd one ortwo numbers or simple pieces of data in the main computer memory (Random Access Memory, or RAM), (2) a simple operation to perform, such as adding the two numbers together, (3) where in the main memory to put the result of this simple operation, and (4) where to find the next instruction to

11、 perform. 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 sequencesof 1s and 0s. A typicalinstructionin a machinelang

12、uage might read10010 11001011 andmean add thecontents ofstorage registerA tothe contentsof storageregister B.2. High-Level LanguagesHigh-levellanguagesare relativelysophisticatedsetsof statementsutilizingwords and syntax from human language. They are more similar to normal human languages than assem

13、bly 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, hig h-level languages must be translated into machine language by another program called a compiler befor

14、e 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 LanguagesComputer programmers use assembly languages to make machine-language programs easier to wr

15、ite. 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

16、ADD B, A in a typical assembly language statement. Assembly languages sharecertain features with machine languages. For instance, it is possible to manipulate specific bits in both assembly and machine languages. Programmers use assemblylanguages when it is important to minimize the time it takes to

17、 run aprogram,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 monitoror the flow of individual characters to a printer.III. Classificat

18、ion of High-Level LanguagesHigh-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

19、complete function are grouped together into a program module, or procedure, and given a name such as “ procedure 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 amini- program. A

20、 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. Fun

21、ctional 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 morerigorous level of programconstruction. Functional languages also allow variables symbols for data thatcan be specified and changed by the

22、user as the program is running to be given values only once. This simplifies programming by reducing the need to be concerned with the exact order of stateme nt executi on, since a variable does not have to be redeclared , or restated, each time it is used in a program stateme nt. Many of the ideas

23、from fun cti on al la nguages have become key partsof many modern proceduralIanguages.Object-orientedIanguagesare outgrowthsof functionalIan guages. In object-orie nted Ian guages,the code used to writethe program and the data processed by the program are grouped together into un its called objects.

24、 Objects are further grouped into classes, which defi nethe 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 havecertain functions associated with them, called methods. The computer accesses an object

25、through the use of one of the object s methods. The method performs some acti on to the data in the object and retur ns this value to the computer.Classes of objects can also be further grouped into hierarchies, in whichobjects of one class can in herit methods from ano ther class. The structure pro

26、vided in object-orie nted Ian guages makes them very useful for complicated program ming tasks. Logic Ian guages use logic as their mathematical base. A logic program con sists of sets of facts and if-the n rules, which specify how one set of facts may be deduced from others, for example: If the sta

27、teme nt X is true, the n the stateme nt Y is false. In the executi on of such a program,an in put stateme ntcan be logically deduced from other stateme nts in the program.Many artificial in tellige nee programs are written in such Ian guages.IV. Lan guage Structure and Comp onentsProgram ming Ian gu

28、ages use specific types of stateme nts, or in struct ions, toprovide functional structure to the program. A statement in a program is a basic sentence that expresses a simple idea its purpose is to give the computer abasic in structi on. Stateme nts defi ne the types of data allowed, how data areto

29、be manipulated, and the ways that procedures and functions work. Programmers use stateme nts to man ipulate com mon comp onents of program ming Ian guages, such data declarations give names and properties to elements of a program calledas variables andmacros (mini-programs withina program).Stateme n

30、ts knownasvariables. Variables can be assigned different values within the program. The properties 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

31、may represent acollection 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 thatare pointers do not themselves have values; instead, they have information that the computer can use to locate some other variable

32、 that is, they point toanother variable. An expression is a piece of a statement that describes a series of computations to be performed on some of the program s variables,such as X+Y/Z, in which the variables are X, Y, and Z and the computationsare addition and division. An assignment statement ass

33、igns a variable a valuederived fromsome expression,whileconditionalstatementsspecifyexpressionsto be testedand thenused toselectwhich otherstatementsshouldbe executednext.Procedure andfunctionstatementsdefine certainblocksof code as proceduresor functions that can then be returned to later in the pr

34、ogram. These statements also define the kinds of variables and parameters 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 mini translation programs called macros. Macros translate

35、segments of code that have been written in a language structure defined by the programmer into statements that the programming language understands.V. HistoryProgramming languages date back almost to the invention of the digital computer in the 1940s. The first assembly languages emerged in the late

36、 1950s with the introduction of commercial computers. The first procedural languages were developed in the late 1950s to early 1960s: FORTRAN, created by John Backus, and then COBOL, created by Grace Hopper The first functional language was LISP, written by John McCarthy4 in the late 1950s. Although

37、 heavily updated, all three languages are still widely used today. In the late 1960s, the first object-oriented languages, such as SIMULA, emerged. Logic languages became well known in the mid 1970swith the introduction of PROLOG6, a language used to program artificial intelligence software. During

38、the 1970s, procedural languages continued to develop with ALGOL, BASIC, PASCAL, C, and A d a SMALLTALK was a highly influential object-oriented language that led to the merging ofobject- oriented and procedural languages in C+ and more recently in JAVA10.Although pure logic languages have declined i

39、n popularity, variations havebecome vitally important in the form of relational languages for modern databases, such as SQL.計算機(jī)程序一、引言 計算機(jī)程序是指導(dǎo)計算機(jī)執(zhí)行某個功能或功能組合的一套指令。要使指令得到執(zhí) 行,計算機(jī)必須執(zhí)行程序,也就是說,計算機(jī)要讀取程序,然后按準(zhǔn)確的順序?qū)嵤┏?序中編碼的步驟,直至程序結(jié)束。一個程序可多次執(zhí)行,而且每次用戶輸給計算機(jī)的 選項和數(shù)據(jù)不同,就有可能得到不同的結(jié)果。程序可分為兩大類:應(yīng)用程序和操作系統(tǒng)。應(yīng)用程序直接為用戶執(zhí)行某項功能

40、, 如字處理或玩游戲。操作系統(tǒng)管理計算機(jī)和與之相連的各種資源和設(shè)備,如隨機(jī)訪問 存儲器、硬盤驅(qū)動器、監(jiān)視器、鍵盤、打印機(jī)和調(diào)制解調(diào)器,以便使其他程序可以使二、程序開發(fā) 軟件設(shè)計者通過特殊的應(yīng)用程序來開發(fā)新程序,這些應(yīng)用程序常被稱作實用程序 或開發(fā)程序。程序員使用稱作文本編輯器的另一種程序,來以稱作編程語言的特殊標(biāo) 記編寫新程序。使用文本編輯器,程序員創(chuàng)建一個文本文件,這個文本文件是一個有 序指令表,也稱為程序源文件。構(gòu)成程序源文件的單個指令被稱為源代碼。在這個時 候,一種特殊的應(yīng)用程序?qū)⒃创a翻譯成機(jī)器語言或目標(biāo)代碼操作系統(tǒng)將認(rèn)作真 程序并能夠執(zhí)行的一種格式。將源代碼翻譯成目標(biāo)代碼的應(yīng)用程序有

41、3 種:編譯器、解釋器和匯編程序。這3種應(yīng)用程序在不同類型的編程語言上執(zhí)行不同的操作,但是它們都起到將編程語言翻 譯成機(jī)器語言的相同目的。編譯器將使用 FORTRAN、 C 和 Pascal 等高級編程語言編寫的文本文件一次性從源 代碼翻譯成目標(biāo)代碼。這不同于 BASIC 等解釋執(zhí)行的語言所采取的方式,在解釋執(zhí)行 的語言中程序是隨著每條指令的執(zhí)行而逐個語句地翻譯成目標(biāo)代碼的。解釋執(zhí)行的語 言的優(yōu)點是,它們可以立即開始執(zhí)行程序,而不需要等到所有的源代碼都得到編譯。 對程序的更改也可以相當(dāng)快地作出,而無需等到重新編譯整個程序。解釋執(zhí)行的語言 的缺點是,它們執(zhí)行起來慢,因為每次運行程序,都必須對整個

42、程序一次一條指令地 翻譯。另一方面,編譯執(zhí)行的語言只編譯一次,因此計算機(jī)執(zhí)行起來要比解釋執(zhí)行的 語言快得多。由于這個原因,編譯執(zhí)行的語言更常使用,而且在專業(yè)和科學(xué)領(lǐng)域幾乎 總是得到采用。另一種翻譯器是匯編程序,它被用于以匯編語言編寫的程序或程序組成部分。匯 編語言也是一種編程語言,但它比其他類型的高級語言更接近于機(jī)器語言。在匯編語 言中,一條語句通??梢苑g成機(jī)器語言的一條指令。今天,匯編語言很少用來編寫 整個程序,而是最經(jīng)常地采用于程序員需要直接控制計算機(jī)某個方面功能的場合。程序經(jīng)常被編寫作一套較小的程序段,每段代表整個應(yīng)用程序的某個方面。各段 獨立編譯之后,一種被稱為連接程序的程序?qū)⑺芯?/p>

43、譯好的程序段組合成一個可以執(zhí) 行的完整程序。程序很少有第一次能夠正確運行的,所以一種被稱為調(diào)試程序的程序常被用來幫 助查找被稱為程序錯誤的問題。調(diào)試程序通常在運行的程序中檢測到一個事件,并向 程序員指出事件在程序代碼中的起源。最近出現(xiàn)的編程系統(tǒng),如 Java ,采取多種方法相結(jié)合的方式創(chuàng)建和執(zhí)行程序。編譯器取來 Java 源程序, 并將其翻譯成中間形式。 這樣的中間程序隨后通過因特網(wǎng)傳送 給計算機(jī),而這些計算機(jī)里的解釋程序接下來將中間程序作為應(yīng)用程序來執(zhí)行。三、程序元素大多數(shù)程序只是由少數(shù)幾種步驟構(gòu)成,這些步驟在整個程序中在不同的上下文和 以不同的組合方式多次重復(fù)。最常見的步驟執(zhí)行某種計算,然

44、后按照程序員指定的順 序,進(jìn)入程序的下一個步驟。程序經(jīng)常需要多次重復(fù)不長的一系列步驟,例如,瀏覽游戲得分表,從中找出最 高得分。這種重復(fù)的代碼序列稱為循環(huán)。計算機(jī)所具有的使其如此有用的能力之一,就是它們能夠作出條件判定,并根據(jù) 正在處理的數(shù)據(jù)的值執(zhí)行不同的指令。 if-then-else (如果則否則)語句通過測 試某個數(shù)據(jù)段,然后根據(jù)結(jié)果從兩個指令序列中選出一個,來執(zhí)行這個功能。這些選 擇對象中的指令之一可能是一個 goto 語句,用以指引計算機(jī)從程序的另一個部分選擇 下一條指令。例如,一個程序可能比較兩個數(shù),并依據(jù)比較的結(jié)果而分支到程序的另 一個部分:If x is greater tha

45、n ythengoto instruction #10else continue程序經(jīng)常不止一次地使用特定的一系列步驟。這樣的一系列步驟可以組合成一個 子例程,而子例程根據(jù)需要可在主程序的不同部分進(jìn)行調(diào)用或訪問。每次調(diào)用一個子 例程,計算機(jī)都會記住它自己在該調(diào)用發(fā)生時處在程序的那個位置,以便在運行完該 子例程后還能夠回到那里。在每次調(diào)用之前,程序可以指定子例程使用不同的數(shù)據(jù), 從而做到一個通用性很強(qiáng)的代碼段只編寫一次,而被以多種方式使用。大多數(shù)程序使用幾種不同的子例程。其中最常用的是函數(shù)、過程、庫程序、系統(tǒng) 程序以及設(shè)備驅(qū)動程序。函數(shù)是一種短子例程,用來計算某個值,如角的計算,而該 值計算機(jī)僅用一條基本指令無法計算。過程執(zhí)行的是復(fù)雜一些的功能,如給一組名稱 排序。庫程序是為許多不同的程序使用而編寫的子例程。系統(tǒng)程序和

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論