已閱讀5頁(yè),還剩4頁(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)介
姓名:劉峻霖班級(jí):通信143班學(xué)號(hào):Computer Language and ProgrammingI. 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. 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.II. 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. 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 Languages 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 generally 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 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 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 sequences of 1s and 0s. 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.2. High-Level Languages 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 Languages 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. 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.III. 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.” 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. 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. IV. Language Structure and ComponentsProgramming 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 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. 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 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 segments of code that have been written in a language structure defined by the programmer into statements that the programming language understands.V. History Programming languages date back almost to the invention of the digital computer in the 1940s. The first assembly 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, created 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 used today. In the late 1960s, the first object-oriented languages, such as SIMULA, emerged. Logic languages became well known in the mid 1970s with the introduction of PROLOG6, 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 language that led to the merging of object- oriented and procedural languages in C+ and more recently in JAVA10. Although pure logic languages have declined in popularity, variations have become vitally important in the form of relational languages for modern 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)器、監(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種:編譯器、解釋器和匯編程序。這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è)程序一次一條指令地翻譯。另一方面,編譯執(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í)行的完整程序。程序很少有第一次能夠正確運(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è)步驟。程序經(jīng)常需要多次重復(fù)不長(zhǎng)的一系列步驟,例如,瀏覽游戲得分表,從中找出最高得分。這種重復(fù)的代碼序列稱為循環(huán)。計(jì)算機(jī)所具有的使其如此有用的能力之一,就是它們能夠作出條件判定,并根據(jù)正在處理的數(shù)據(jù)的值執(zhí)行不同的指令。if-then-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 than ythengoto instruction #10else continue程序經(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ì)算,而
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 醫(yī)院清潔員考核制度
- 娛樂(lè)公司考核制度
- 證券開(kāi)戶數(shù)考核制度
- 村社區(qū)目標(biāo)考核制度
- 如何做pk考核制度
- 廚房衛(wèi)生考核制度
- 自管委量化考核制度
- 學(xué)生會(huì)部員考核制度
- 明朝國(guó)子監(jiān)考核制度
- 學(xué)生會(huì)新生考核制度
- 2026年春大象版新教材小學(xué)科學(xué)二年級(jí)下冊(cè)(全冊(cè))教學(xué)設(shè)計(jì)(附目錄P130)
- 2026年二手車評(píng)估與交易流程優(yōu)化指南
- 2026年渭南職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫(kù)必考題
- 2025比亞迪供應(yīng)商審核自查表
- 谷雨生物2024環(huán)境、社會(huì)及管治(ESG)報(bào)告
- 2025金風(fēng)變流器2.0MW故障代碼手冊(cè)V4
- 房地產(chǎn)估價(jià)試題及答案
- 血管內(nèi)超聲(IVUS)的簡(jiǎn)介及適應(yīng)癥
- 腰椎手術(shù)的手術(shù)指征和手術(shù)方法選擇
- 抗菌藥物臨床應(yīng)用指導(dǎo)原則
- GB/T 7025.1-2023電梯主參數(shù)及轎廂、井道、機(jī)房的型式與尺寸第1部分:Ⅰ、Ⅱ、Ⅲ、Ⅵ類電梯
評(píng)論
0/150
提交評(píng)論