版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、<p><b> 英文資料翻譯</b></p><p> Computer Language and Programming</p><p> I. Introduction </p><p> Programming languages, in computer science, are the artificial lan
2、guages 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, na
3、tural 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 comput</p
4、><p> 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 par
5、ticular model of computer system. For instance, programming languages such as FORTRAN and COBOL were written to solve certain general types of programming problems—FORTRAN for scientific applications, and COBOL for busin
6、ess applications. Although these languages were designed to address specific </p><p> II. Language Types </p><p> Programming languages can be classified as either low-level languages or high-
7、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 manufacture
8、r 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-</p><p&
9、gt; 1. Machine Languages </p><p> In machine languages, instructions are written as sequences of 1s and 0s, called bits, that a computer can understand directly. An instruction in machine language generall
10、y tells the computer four things: (1) where to find one or two 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 number
11、s together, (3) where in the main memory to put the result of this simple operation, and (4) where to find th</p><p> 2. High-Level Languages </p><p> High-level languages are relatively sophi
12、sticated 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 progr
13、ams. 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 com
14、puter can understan</p><p> 3. Assembly Languages </p><p> Computer programmers use assembly languages to make machine-language programs easier to write. In an assembly language, each statemen
15、t 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 o
16、f storage register B might be written ADD B, A in a typical assembly language statement. Assembly languages share certain features with machine lan</p><p> languages when it is important to minimize the tim
17、e 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
18、 individual dots on a monitor or the flow of individual characters to a printer.</p><p> III. Classification of High-Level Languages </p><p> High-level languages are commonly classified as pr
19、ocedure-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 so
20、me 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
21、 to refer </p><p> 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 compu
22、ter to read, but they require the programmer to design each procedure to be general enough to be used </p><p> in different situations. Functional languages treat procedures like mathematical functions and
23、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 variables—symbols for data that can be specified a
24、nd changed by the 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 statement executi</p><p> Classes of o
25、bjects 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 progra
26、mming 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
27、 X is true, then the statement Y is false. In th</p><p> IV. Language Structure and Components</p><p> Programming languages use specific types of statements, or instructions, to provide funct
28、ional 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 a basic instruction. Statements define the types of data allowed, how data are
29、 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-pr</p><p> Proced
30、ure 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 the programmer ca
31、n 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 segments of
32、 code that have been written in a language structure d</p><p> V. History </p><p> Programming languages date back almost to the invention of the digital computer in the 1940s. The first assem
33、bly languages emerged in the late 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, crea
34、ted by Grace Hopper The first functional language was LISP, written by John McCarthy4 in the late 1950s. Although heavily updated, all three languages are still widely use</p><p> with the introduction of P
35、ROLOG6, a language used to program artificial intelligence software. During the 1970s, procedural languages continued to develop with ALGOL, BASIC, PASCAL, C, and A d a SMALLTALK was a highly influential object-oriented
36、language that led to the merging of </p><p> object- oriented and procedural languages in C++ and more recently in JAVA10. Although pure logic languages have declined in popularity, variations have become v
37、itally important in the form of relational languages for modern databases, such as SQL.</p><p><b> 計算機程序</b></p><p><b> 一、引言</b></p><p> 計算機程序是指導計算機執(zhí)行某個功能
38、或功能組合的一套指令。要使指令得到執(zhí)行,計算機必須執(zhí)行程序,也就是說,計算機要讀取程序,然后按準確的順序?qū)嵤┏绦蛑芯幋a的步驟,直至程序結(jié)束。一個程序可多次執(zhí)行,而且每次用戶輸給計算機的選項和數(shù)據(jù)不同,就有可能得到不同的結(jié)果。</p><p> 程序可分為兩大類:應用程序和操作系統(tǒng)。應用程序直接為用戶執(zhí)行某項功能,如字處理或玩游戲。操作系統(tǒng)管理計算機和與之相連的各種資源和設備,如隨機訪問存儲器、硬盤驅(qū)動器、監(jiān)視器
39、、鍵盤、打印機和調(diào)制解調(diào)器,以便使其他程序可以使用它們。操作系統(tǒng)的例子包括:DOS、Windows 95、OS/2和UNIX。</p><p><b> 二、程序開發(fā)</b></p><p> 軟件設計者通過特殊的應用程序來開發(fā)新程序,這些應用程序常被稱作實用程序或開發(fā)程序。程序員使用稱作文本編輯器的另一種程序,來以稱作編程語言的特殊標記編寫新程序。使用文本編輯器
40、,程序員創(chuàng)建一個文本文件,這個文本文件是一個有序指令表,也稱為程序源文件。構成程序源文件的單個指令被稱為源代碼。在這個時候,一種特殊的應用程序?qū)⒃创a翻譯成機器語言或目標代碼——操作系統(tǒng)將認作真程序并能夠執(zhí)行的一種格式。</p><p> 將源代碼翻譯成目標代碼的應用程序有3種:編譯器、解釋器和匯編程序。這3種應用程序在不同類型的編程語言上執(zhí)行不同的操作,但是它們都起到將編程語言翻譯成機器語言的相同目的。<
41、;/p><p> 編譯器將使用FORTRAN、C和Pascal等高級編程語言編寫的文本文件一次性從源代碼翻譯成目標代碼。這不同于BASIC等解釋執(zhí)行的語言所采取的方式,在解釋執(zhí)行的語言中程序是隨著每條指令的執(zhí)行而逐個語句地翻譯成目標代碼的。解釋執(zhí)行的語言的優(yōu)點是,它們可以立即開始執(zhí)行程序,而不需要等到所有的源代碼都得到編譯。對程序的更改也可以相當快地作出,而無需等到重新編譯整個程序。解釋執(zhí)行的語言的缺點是,它們執(zhí)行
42、起來慢,因為每次運行程序,都必須對整個程序一次一條指令地翻譯。另一方面,編譯執(zhí)行的語言只編譯一次,因此計算機執(zhí)行起來要比解釋執(zhí)行的語言快得多。由于這個原因,編譯執(zhí)行的語言更常使用,而且在專業(yè)和科學領域幾乎總是得到采用。</p><p> 另一種翻譯器是匯編程序,它被用于以匯編語言編寫的程序或程序組成部分。匯編語言也是一種編程語言,但它比其他類型的高級語言更接近于機器語言。在匯編語言中,一條語句通??梢苑g成機器
43、語言的一條指令。今天,匯編語言很少用來編寫整個程序,而是最經(jīng)常地采用于程序員需要直接控制計算機某個方面功能的場合。</p><p> 程序經(jīng)常被編寫作一套較小的程序段,每段代表整個應用程序的某個方面。各段獨立編譯之后,一種被稱為連接程序的程序?qū)⑺芯幾g好的程序段組合成一個可以執(zhí)行的完整程序。</p><p> 程序很少有第一次能夠正確運行的,所以一種被稱為調(diào)試程序的程序常被用來幫助查找
44、被稱為程序錯誤的問題。調(diào)試程序通常在運行的程序中檢測到一個事件,并向程序員指出事件在程序代碼中的起源。</p><p> 最近出現(xiàn)的編程系統(tǒng),如Java,采取多種方法相結(jié)合的方式創(chuàng)建和執(zhí)行程序。編譯器取來Java源程序,并將其翻譯成中間形式。這樣的中間程序隨后通過因特網(wǎng)傳送給計算機,而這些計算機里的解釋程序接下來將中間程序作為應用程序來執(zhí)行。</p><p><b> 三、程
45、序元素</b></p><p> 大多數(shù)程序只是由少數(shù)幾種步驟構成,這些步驟在整個程序中在不同的上下文和以不同的組合方式多次重復。最常見的步驟執(zhí)行某種計算,然后按照程序員指定的順序,進入程序的下一個步驟。</p><p> 程序經(jīng)常需要多次重復不長的一系列步驟,例如,瀏覽游戲得分表,從中找出最高得分。這種重復的代碼序列稱為循環(huán)。</p><p>
46、計算機所具有的使其如此有用的能力之一,就是它們能夠作出條件判定,并根據(jù)正在處理的數(shù)據(jù)的值執(zhí)行不同的指令。if-then-else(如果-則-否則)語句通過測試某個數(shù)據(jù)段,然后根據(jù)結(jié)果從兩個指令序列中選出一個,來執(zhí)行這個功能。這些選擇對象中的指令之一可能是一個goto語句,用以指引計算機從程序的另一個部分選擇下一條指令。例如,一個程序可能比較兩個數(shù),并依據(jù)比較的結(jié)果而分支到程序的另一個部分:</p><p> I
47、f x is greater than y</p><p><b> then</b></p><p> goto instruction #10</p><p> else continue</p><p> 程序經(jīng)常不止一次地使用特定的一系列步驟。這樣的一系列步驟可以組合成一個子例程,而子例程根據(jù)需要可在主程
48、序的不同部分進行調(diào)用或訪問。每次調(diào)用一個子例程,計算機都會記住它自己在該調(diào)用發(fā)生時處在程序的那個位置,以便在運行完該子例程后還能夠回到那里。在每次調(diào)用之前,程序可以指定子例程使用不同的數(shù)據(jù),從而做到一個通用性很強的代碼段只編寫一次,而被以多種方式使用。</p><p> 大多數(shù)程序使用幾種不同的子例程。其中最常用的是函數(shù)、過程、庫程序、系統(tǒng)程序以及設備驅(qū)動程序。函數(shù)是一種短子例程,用來計算某個值,如角的計算,而
49、該值計算機僅用一條基本指令無法計算。過程執(zhí)行的是復雜一些的功能,如給一組名稱排序。庫程序是為許多不同的程序使用而編寫的子例程。系統(tǒng)程序和庫程序相似,但實際上用于操作系統(tǒng)。它們?yōu)閼贸绦蛱峁┠撤N服務,如打印一行文字。設備驅(qū)動程序是一種系統(tǒng)程序,它們加到操作系統(tǒng)中,以使計算機能夠與掃描儀、調(diào)制解調(diào)器或打印機等新設備進行通信。設備驅(qū)動程序常常具有可以直接作為應用程序執(zhí)行的特征。這樣就使用戶得以直接控制該設備。這一點很有用,例如,在彩色打印機更
50、換墨盒后,需要重新調(diào)整以達到最佳打印質(zhì)量的情況下。</p><p><b> 四、程序功能</b></p><p> 現(xiàn)代計算機通常將程序存儲在計算機可以隨機訪問的某種形式的磁性存儲介質(zhì)上,如固定放在計算機中的硬盤或者便攜式的軟盤。這些磁盤上被稱為目錄的額外信息,指明盤上各種程序的名稱、它們寫入盤中的時間以及它們在磁盤介質(zhì)上的開始位置。當用戶命令計算機執(zhí)行一個特定
51、應用程序時,操作系統(tǒng)就瀏覽這些目錄,找到程序,并將一個副本讀入隨機存儲器。操作系統(tǒng)然后命令中央處理器在程序的起始位置開始執(zhí)行指令。程序起始位置的指令為計算機處理信息作好準備,其方法是在隨機存儲器中找到閑置內(nèi)存位置來容納工作數(shù)據(jù),從盤中取回用戶指出的標準方式選項和默認值的副本,并在監(jiān)視器上繪制初始顯示。</p><p> 應用程序通過調(diào)用系統(tǒng)程序而對用戶輸入的任何信息都要求一個副本。操作系統(tǒng)將如此輸入的任何數(shù)據(jù)轉(zhuǎn)
52、換成標準的內(nèi)部形式。應用程序然后使用該信息決定下一步干什么——例如,執(zhí)行某項期望的處理功能——如重新定義一頁文本的格式,或者從盤上的另一個文件獲取某些額外信息。兩種情況無論是哪一種,都要調(diào)用其他系統(tǒng)程序,以事實上完成結(jié)果的顯示或?qū)ΡP上文件的訪問。</p><p> 運行結(jié)束或接到退出的提示時,應用程序進行進一步的系統(tǒng)調(diào)用,以確保所有需要保存的數(shù)據(jù)已寫回磁盤。然后,應用程序向操作系統(tǒng)進行最后一次系統(tǒng)調(diào)用,指明它已
53、運行結(jié)束。操作系統(tǒng)接下來釋放隨機存儲器和該應用程序使用的任何設備,并等待用戶的命令,以開始運行另一個程序。</p><p><b> 五、歷史</b></p><p> 人們用程序的形式存儲一系列指令已經(jīng)有幾個世紀了。18世紀的音樂盒和19世紀末與20世紀初的自動鋼琴,就可以播放音樂程序。這些程序以一系列金屬針或紙孔的形式存儲,每一行(針或孔)表示何時演奏一個音符
54、,而針或孔則表明此時演奏什么音符。19世紀初,隨著法國發(fā)明家約瑟夫―瑪麗?雅卡爾的由穿孔卡片控制的織機的發(fā)明,對物理設備更精巧的控制變得常見了。在編織特定圖案的過程中,織機的各個部分得進行機械定位。為了使這個過程自動化,雅卡爾使用一張紙質(zhì)卡片代表織機的一個定位,用卡片上的孔來指示該執(zhí)行織機的哪個操作。整條花毯的編織可被編碼到一疊這樣的卡片上,同樣的一疊卡片每次使用都會編出相同的花毯圖案。在開發(fā)和使用的程序中,有的由24,000多張卡片構
55、成。</p><p> 世界上第一臺可編程的機器是由英國數(shù)學家和發(fā)明家查爾斯?巴比奇設計的,但從未完全制造成。這臺叫做分析機的機器,使用和雅卡爾的織機類似的穿孔卡片來選擇每個步驟應執(zhí)行的具體算術運算。插入不同的卡片組,就會改變機器執(zhí)行的運算。這種機器幾乎能在現(xiàn)代計算機中找到所有的對應物,但它是機械化的,而非電氣化的。分析機的制造從未完成,因為制造它所需要的技術當時不存在。</p><p>
56、; 供分析機使用的最早卡片組程序是由詩人拜倫勛爵的女兒、英國數(shù)學家奧古斯塔?埃達?拜倫開發(fā)的。由于這個原因,她被確認為世界上第一位程序員。</p><p> 現(xiàn)代的內(nèi)部存儲計算機程序的概念是由美籍匈牙利數(shù)學家約翰??馮?諾伊曼于1945年首先提出來的。馮?諾伊曼的想法是使用計算機的存儲器來既存儲數(shù)據(jù)又存儲程序。這樣,程序可被視作數(shù)據(jù),可像數(shù)據(jù)一樣被其他程序處理。這一想法極大地簡化了計算機中的程序存儲與執(zhí)行的任
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
評論
0/150
提交評論