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

下載本文檔

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

文檔簡(jiǎn)介

1、姓名:劉峻霖班級(jí):通信143班 學(xué)號(hào)Computer Language and Programmingl. l ntroducti onProgram ming Ian guages, in computer scie nee, are the artificial la nguages used to write a seque nee ofin structi ons (a computer program) that can be run by a computer. Similar ton atural lan guages, suchas English, programming l

2、anguages have a vocabulary, grammar, and syntax. However, natural lan guages are not suited for program ming computers because they are ambiguous,meaning that theirvocabulary and grammatical structure may be interpreted in multiple ways. The languages used to program computers must have simple logic

3、al structures, and the rules for their grammar, spelling, and pun ctuati on must be precise.Programmi ng lan guages vary greatly in their sophisticati on and in their degree of versatility. Some program ming lan guages are writte n to address a particular kind of comput ing problem or for use on a p

4、articular model of computer system. For in sta nee, program ming lan guages such as FORTRANandCOBOL were written to solve certain general types of programming problems FORTRAN for scie ntificapplicati ons, and COBOL for bus in ess applicati ons. Although these lan guages weredesig ned to address spe

5、cific categories of computer problems, they are highly portable, meaning that they may be used to program many types of computers. Other lan guages, such as machi ne lan guages, are desig ned to be used by one specific model of computer system, or eve n by one specific computer in certain research a

6、pplications. The most commonly used programming l anguages are highly portable and can be used to effectively solve diverse types of computi ng problems. Lan guages like C, PASCAL and BASIC fall into this category.II. Lan guage TypesProgramminglanguages can be classified as either low-levellanguages

7、 or high-level languages.Low-level programminglanguages, or machine languages, are the most basic type of programminglan guages and can be un derstood directly by a computer. Mach ine lan guages differ depe nding on theman ufacturerand model of computer.High-levellanguages are programming languages

8、that mustfirst be translatedinto a machine language before they can be understood and processed by acomputer. Examples of high-levellanguages are C, C+, PASCAL,and FORTRAN. Assemblylan guages are in termediatelan guages that are very close to mach ine lan guages and do not have the level of li nguis

9、tic sophisticati on exhibited by other high-level la nguages, but must still be tra nslatedinto mach ine Ian guage.1. Machi ne Lan guagesIn machi ne Ian guages, in structi ons are writte n as seque nces of 1s and Os, called bits, that a computer can un dersta nd directly. An in structi on in mach in

10、e lan guage gen erally tells the computer four thi ngs:(1) where to find one or two numbers or simplepieces ofdata in themaincomputermem ory(Random Access Memory, or RAM), (2) a simpleoperationto perform,suchas addingthe twon umbers together, (3) where in the main memory to put the result of this si

11、mple operati on, and (4) where to find the n ext in structi on to perform. While all executable programs are eve ntually read bythe computer in mach ine lan guage, they are not all programmed in mach ine lan guage. It is extremely difficult to program directly in mach ine lan guage because the in st

12、ructi ons are seque nces of 1s and 0s.A typical in structi on in a machi ne lan guage might read 10010 1100 1011 and mean add the contents of storage register A to the contents of storage register B.2. High-Level Lan guagesHigh-level la nguages are relatively sophisticated sets of stateme nts utiliz

13、i ng words and syn tax fromhuman 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 lan guages allow larger and more complicated programs to be developed faster. However, hig

14、h-level lan guages must be tra nslated into mach ine lan guage by ano ther program called a compiler before a computer can un dersta nd them. For this reas on, programs writte n in a high-level la nguage may takelon ger to execute and use up more memory tha n programs writte n in an assembly lan gua

15、ge.3. Assembly Lan guagesComputer programmers use assembly lan guages to make mach in e-la nguage programs easier to write.In an assemblylanguage,each statement correspondsroughly to onemachine l anguage instruction.An assemblylan guagestateme ntis composedwith the aid ofeasy to remember comma nds.

16、Thecomma nd to add the contents of the storage register A to the contents of storage register B might be written ADDB, A ina typicalassembly language statement.Assembly languages share certainfeatures withmachinelanguages.For instanee,it is possibleto manipulate specific bits in bothassembly and mac

17、hi ne lan guages. Programmers use assemblylan guages whe n it is importa nt to mini mize the time it takes to run a program, because the tran slati on from assembly lan guage to mach ine lan guage is relatively simple. Assembly lan guages are also used whe n some part of the computer has to be con t

18、rolled directly, such as in dividual dots on a mon itor or the flow of i ndividual characters to a pri nter.III. Classificati on of High-Level Lan guagesHigh-level la nguages are com monly classified as procedure-orie nted, fun cti on al, object-orie nted, or logic lan guages. The most com mon high-

19、level la nguages today are procedure-orie nted lan guages. In these lan guages, one or more related blocks of stateme nts that perform some complete fun cti on are grouped together into a program module, or procedure, and given a name such as“ procedure A. ”the same seque nee of operati ons is n eed

20、ed elsewhere in the program, a simple stateme nt can be used to refer back to the procedure .In esse nee, a procedure is just a mini- program. A large program can be constructed by grouping together procedures that perform differe nt tasks.Procedural la nguages allow programs to be shorter and easie

21、r for the computer toread, but they require the programmer to desig n each procedure to be gen eral en ough to be usedin differe nt situati ons. Fun cti on al la nguages treat procedures like mathematical fun ctions and allowthem to be processed like any other data in a program. This allows a much h

22、igher and more rigorous level of program con structi on. Fun cti on al la nguages also allow variables symbols for datathat can be specified and changed by the user as the program is running to be given values only once. This simplifiesprogrammingby reducing the need to be concerned with the exact o

23、rder ofstateme 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 from fun cti on al la nguages have become key parts of many moder n procedural la nguages. Object-orie nted lan guages are outgrowths of fun ct

24、i onal lan guages. In object-orie nted lan guages, the code used to write the program and the data processed by the program are grouped together into un its called objects. Objects are further grouped into classes, which defi ne the attributes objects must have. A simple example of a class is the cl

25、ass 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 object s methods.method performs some acti on to the data in the object and returns this value t

26、o thecomputer.Classes of objects can also be further grouped into hierarchies, in which objects of one class can in herit methods from ano ther class. The structure provided in object-orie nted lan guages makes themvery useful for complicated programming tasks. Logic languages use logic as their mat

27、hematical 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 stateme nt X is true, the n the stateme nt Y is false. In the executi on of such a program, an in put stateme nt can be logically deduced

28、from other stateme nts in the program. Many artificial in tellige nee programs are writte n in such lan guages.IV. Lan guage Structure and Comp onentsProgramming Ianguages use specific types of statements, or instructions, to provide functional structure to the program. A statement in a program is a

29、 basic sentence that expresses a simple idea its purpose is to give the computer a basic instruction.Statements define the types of dataallowed, how data are to be manipulated, and the ways that procedures and functions work. Programmers use stateme nts to man ipulate com mon comp onents of program

30、ming lan guages, such as variables and macros (mi ni-programs within a program). Stateme nts known as data declarati ons give n ames and properties to eleme nts of a program called variables. Variables can be assig ned differe nt values within the program. The properties variables can have are calle

31、d types, and they in clude such things as what possible values might be saved in the variables, howmuch n umerical accuracy is tobe 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 programminglanguages, a

32、 key data type is apoin ter. Variables that are poi nters do not themselves have values; in stead, they have in formatio n that the computer can use to locate some other variablethat is, they point to ano ther variable. Anexpressi on is a piece of a stateme nt that describes a series of computati on

33、s to be performed on some of the program s/ariables, such as X+Y/Z, in which the variables are X, Y, andZ and thecomputati ons are additi on and divisi on. An assig nment stateme nt assig ns a variable a value derived from some expressi on, while con diti onal stateme nts specify expressi ons to be

34、tested and the n used to select which other stateme nts should be executed n ext.Procedure and fun cti on stateme nts defi ne certa in blocks of code as procedures or fun cti ons that can then be returned to later in the program. These statements also define the kinds of variables and parameters the

35、 programmercan choose and the type of value that the code will return when anexpression accesses the procedure or function. Many programming languages also permit mini translationprograms called macros. Macros translate segments of code that have been written in alan guage structure defi ned by the

36、programmer in to stateme nts that the program minglan guageun dersta nds.V. HistoryProgram ming lan guages date back almost to the inven ti on of the digital computer in the 1940s. The first assembly lan guages emerged in the late 1950s with the in troducti on of commercial computers.The first proce

37、dural la nguages were developed in the late 1950s to early 1960s:FORTRAN, createdby Joh n Backus, and the n COBOL, created by Grace Hopper The first fun cti on al la nguage was LISP, writte n by Joh n McCarthy4 in the late 1950s. Although heavily updated, all three lan guages are still widely used t

38、oday .In the late 1960s, the first object-orie nted lan guages, such as SIMULA, emerged.Logic Ian guages became well known in the mid 1970swith the introduction of PROLOG6, a language used to program artificialintelligenee software.During the 1970s, procedural languages continued to develop with ALG

39、OL, BASIC, PASCAL, C, and A d a SMALLTALK was a highly in flue ntial object-orie nted lan guage that led to the merg ing ofobject- oriented and procedural languages in C+ and more recently in JAVA10. Although pure logic lan guages have decli ned in popularity, variati ons have become vitally importa

40、 nt in the form of relati on al la nguages for moder n databases, such as SQL.計(jì)算機(jī)程序一、引言計(jì)算機(jī)程序是指導(dǎo)計(jì)算機(jī)執(zhí)行某個(gè)功能或功能組合的一套指令。要使指令得到執(zhí)行,計(jì)算機(jī)必須執(zhí)行程序,也就是說(shuō),計(jì)算機(jī)要讀取程序,然后按準(zhǔn)確的順序?qū)嵤┏绦蛑芯幋a的步驟,直至程序結(jié)束。一個(gè)程序可多次執(zhí)行,而且每次用戶輸給計(jì)算機(jī)的選項(xiàng)和數(shù)據(jù)不同,就有可能 得到不同的結(jié)果。程序可分為兩大類:應(yīng)用程序和操作系統(tǒng)。應(yīng)用程序直接為用戶執(zhí)行某項(xiàng)功能,如字處理 或玩游戲。操作系統(tǒng)管理計(jì)算機(jī)和與之相連的各種資源和設(shè)備,如隨機(jī)訪問(wèn)存儲(chǔ)器、硬盤(pán)驅(qū)動(dòng) 器

41、、監(jiān)視器、鍵盤(pán)、打印機(jī)和調(diào)制解調(diào)器,以便使其他程序可以使用它們。操作系統(tǒng)的例子包 括:DOS、Windows 95 、OS/2 和 UNIX。二、程序開(kāi)發(fā)軟件設(shè)計(jì)者通過(guò)特殊的應(yīng)用程序來(lái)開(kāi)發(fā)新程序,這些應(yīng)用程序常被稱作實(shí)用程序或開(kāi)發(fā)程序。程序員使用稱作文本編輯器的另一種程序,來(lái)以稱作編程語(yǔ)言的特殊標(biāo)記編寫(xiě)新程序。使 用文本編輯器,程序員創(chuàng)建一個(gè)文本文件,這個(gè)文本文件是一個(gè)有序指令表,也稱為程序源文 件。構(gòu)成程序源文件的單個(gè)指令被稱為源代碼。在這個(gè)時(shí)候,一種特殊的應(yīng)用程序?qū)⒃创a翻 譯成機(jī)器語(yǔ)言或目標(biāo)代碼一一操作系統(tǒng)將認(rèn)作真程序并能夠執(zhí)行的一種格式。將源代碼翻譯成目標(biāo)代碼的應(yīng)用程序有3種:編譯器、

42、解釋器和匯編程序。這3種應(yīng)用程序在不同類型的編程語(yǔ)言上執(zhí)行不同的操作,但是它們都起到將編程語(yǔ)言翻譯成機(jī)器語(yǔ)言的相 同目的。編譯器將使用 FORTRAN 、C和Pascal等高級(jí)編程語(yǔ)言編寫(xiě)的文本文件一次性從源代碼翻 譯成目標(biāo)代碼。這不同于BASIC等解釋執(zhí)行的語(yǔ)言所采取的方式,在解釋執(zhí)行的語(yǔ)言中程序是隨著每條指令的執(zhí)行而逐個(gè)語(yǔ)句地翻譯成目標(biāo)代碼的。解釋執(zhí)行的語(yǔ)言的優(yōu)點(diǎn)是,它們可以立 即開(kāi)始執(zhí)行程序,而不需要等到所有的源代碼都得到編譯。對(duì)程序的更改也可以相當(dāng)快地作岀,而無(wú)需等到重新編譯整個(gè)程序。解釋執(zhí)行的語(yǔ)言的缺點(diǎn)是,它們執(zhí)行起來(lái)慢,因?yàn)槊看芜\(yùn)行程 序,都必須對(duì)整個(gè)程序一次一條指令地翻譯。另一方

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

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

45、序經(jīng)常需要多次重復(fù)不長(zhǎng)的一系列步驟,例如,瀏覽游戲得分表,從中找岀最高得分。 這種重復(fù)的代碼序列稱為循環(huán)。計(jì)算機(jī)所具有的使其如此有用的能力之一,就是它們能夠作岀條件判定,并根據(jù)正在處理 的數(shù)據(jù)的值執(zhí)行不同的指令。if-the n-else (如果則否則)語(yǔ)句通過(guò)測(cè)試某個(gè)數(shù)據(jù)段,然后根據(jù)結(jié)果從兩個(gè)指令序列中選岀一個(gè),來(lái)執(zhí)行這個(gè)功能。這些選擇對(duì)象中的指令之一可能是一 個(gè)goto語(yǔ)句,用以指引計(jì)算機(jī)從程序的另一個(gè)部分選擇下一條指令。例如,一個(gè)程序可能比較 兩個(gè)數(shù),并依據(jù)比較的結(jié)果而分支到程序的另一個(gè)部分:If x is greater tha n ythe ngoto in structi on #10else con ti nue程序經(jīng)常不止一次地使用特定的一系列步驟。這樣的一系列步驟可以組合成一個(gè)子例程, 而子例程根據(jù)需要可在主程序的不同部分進(jìn)行調(diào)用或訪問(wèn)。每次調(diào)用一個(gè)子例程,計(jì)算機(jī)都會(huì) 記住它自己在該調(diào)用發(fā)生時(shí)處在程序的那個(gè)位置,以便在運(yùn)行完該子例程后還能夠回到那里。在每次調(diào)用之前,程序可以指定子例程使用不同的數(shù)據(jù),從而做到一個(gè)通用性很強(qiáng)的代碼段只編寫(xiě)一次,而被以多種方式使用。大多數(shù)程序使用幾種不同的子例程。其中最常用的是函數(shù)、過(guò)程、庫(kù)程序、系統(tǒng)程序以及設(shè)備驅(qū)動(dòng)程序。函數(shù)是一種短子例程,用來(lái)計(jì)算某個(gè)值,如角的計(jì)算,而該值計(jì)算機(jī)僅

溫馨提示

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

評(píng)論

0/150

提交評(píng)論