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

下載本文檔

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

文檔簡介

1、姓名:劉峻霖班級:通信143班學(xué)號:2014101108ComputerLanguageandProgrammingI. IntroductionProgramminglanguages,incomputerscience,aretheartificiallanguagesusedtowriteasequenceofinstructions(acomputerprogram)thatcanberunbyacomputer.Similartonaturallanguages,suchasEnglish,programminglanguageshaveavocabulary,grammar,and

2、syntax.However,naturallanguagesarenotsuitedforprogrammingcomputersbecausetheyareambiguous,meaningthattheirvocabularyandgrammaticalstructuremaybeinterpretedinmultipleways.Thelanguagesusedtoprogramcomputersmusthavesimplelogicalstructures,andtherulesfortheirgrammar,spelling,andpunctuationmustbeprecise.

3、Programminglanguagesvarygreatlyintheirsophisticationandintheirdegreeofversatility.Someprogramminglanguagesarewrittentoaddressaparticularkindofcomputingproblemorforuseonaparticularmodelofcomputersystem.Forinstance,programminglanguagessuchasFORTRANandCOBOLwerewrittentosolvecertaingeneraltypesofprogram

4、mingproblemsFORTRANforscientificapplications,andCOBOLforbusinessapplications.Althoughtheselanguagesweredesignedtoaddressspecificcategoriesofcomputerproblems,theyarehighlyportable,meaningthattheymaybeusedtoprogrammanytypesofcomputers.Otherlanguages,suchasmachinelanguages,aredesignedtobeusedbyonespeci

5、ficmodelofcomputersystem,orevenbyonespecificcomputerincertainresearchapplications.Themostcommonlyusedprogramminglanguagesarehighlyportableandcanbeusedtoeffectivelysolvediversetypesofcomputingproblems.LanguageslikeC,PASCALandBASICfallintothiscategory.II. LanguageTypesProgramminglanguagescanbeclassifi

6、edaseitherlow-levellanguagesorhigh-levellanguages.Low-levelprogramminglanguages,ormachinelanguages,arethemostbasictypeofprogramminglanguagesandcanbeunderstooddirectlybyacomputer.Machinelanguagesdifferdependingonthemanufacturerandmodelofcomputer.High-levellanguagesareprogramminglanguagesthatmustfirst

7、betranslatedintoamachinelanguagebeforetheycanbeunderstoodandprocessedbyacomputer.Examplesofhigh-levellanguagesareC,C+,PASCAL,andFORTRAN.Assemblylanguagesareintermediatelanguagesthatareveryclosetomachinelanguagesanddonothavetheleveloflinguisticsophisticationexhibitedbyotherhigh-levellanguages,butmust

8、stillbetranslatedintomachinelanguage.1. MachineLanguagesInmachinelanguages,instructionsarewrittenassequencesof1sand0s,calledbits,thatacomputercanunderstanddirectly.Aninstructioninmachinelanguagegenerallytellsthecomputerfourthings:wheretofindoneortwonumbersorsimplepiecesofdatainthemaincomputermemory(

9、RandomAccessMemory,orRAM),(2)asimpleoperationtoperform,suchasaddingthetwonumberstogether,(3)whereinthemainmemorytoputtheresultofthissimpleoperation,and(4)wheretofindthenextinstructiontoperform.Whileallexecutableprogramsareeventuallyreadbythecomputerinmachinelanguage,theyarenotallprogrammedinmachinel

10、anguage.Itisextremelydifficulttoprogramdirectlyinmachinelanguagebecausetheinstructionsaresequencesof1sand0s.Atypicalinstructioninamachinelanguagemightread1001011001011andmeanaddthecontentsofstorageregisterAtothecontentsofstorageregisterB.2. High-LevelLanguagesHigh-levellanguagesarerelativelysophisti

11、catedsetsofstatementsutilizingwordsandsyntaxfromhumanlanguage.Theyaremoresimilartonormalhumanlanguagesthanassemblyormachinelanguagesandarethereforeeasiertouseforwritingcomplicatedprograms.Theseprogramminglanguagesallowlargerandmorecomplicatedprogramstobedevelopedfaster.However,high-levellanguagesmus

12、tbetranslatedintomachinelanguagebyanotherprogramcalledacompilerbeforeacomputercanunderstandthem.Forthisreason,programswritteninahigh-levellanguagemaytakelongertoexecuteanduseupmorememorythanprogramswritteninanassemblylanguage.3. AssemblyLanguagesComputerprogrammersuseassemblylanguagestomakemachine-l

13、anguageprogramseasiertowrite.Inanassemblylanguage,eachstatementcorrespondsroughlytoonemachinelanguageinstruction.Anassemblylanguagestatementiscomposedwiththeaidofeasytoremembercommands.ThecommandtoaddthecontentsofthestorageregisterAtothecontentsofstorageregisterBmightbewrittenADDB,Ainatypicalassembl

14、ylanguagestatement.Assemblylanguagessharecertainfeatureswithmachinelanguages.Forinstance,itispossibletomanipulatespecificbitsinbothassemblyandmachinelanguages.Programmersuseassemblylanguageswhenitisimportanttominimizethetimeittakestorunaprogram,becausethetranslationfromassemblylanguagetomachinelangu

15、ageisrelativelysimple.Assemblylanguagesarealsousedwhensomepartofthecomputerhastobecontrolleddirectly,suchasindividualdotsonamonitorortheflowofindividualcharacterstoaprinter.III. ClassificationofHigh-LevelLanguagesHigh-levellanguagesarecommonlyclassifiedasprocedure-oriented,functional,object-oriented

16、,orlogiclanguages.Themostcommonhigh-levellanguagestodayareprocedure-orientedlanguages.Intheselanguages,oneormorerelatedblocksofstatementsthatperformsomecompletefunctionaregroupedtogetherintoaprogrammodule,orprocedure,andgivenanamesuchas“procedureA."Ifthesamesequenceaoooperneededelsewhereinthepr

17、ogram,asimplestatementcanbeusedtoreferbacktotheprocedure.Inessence,aprocedureisjustamini-program.Alargeprogramcanbeconstructedbygroupingtogetherproceduresthatperformdifferenttasks.Procedurallanguagesallowprogramstobeshorterandeasierforthecomputertoread,buttheyrequiretheprogrammertodesigneachprocedur

18、etobegeneralenoughtobeusedindifferentsituations.Functionallanguagestreatprocedureslikemathematicalfunctionshigherandmorerigorouslevelandallowthemtobeprocessedlikeanyotherdatainaprogram.Thisallowsamuchofprogramconstruction.Functionallanguagesalsobytheuserastheallowvariablessymbolsfordatathatcanbespec

19、ifiedandchangedprogramisrunningtobegivenvaluesonlyonce.Thissimplifiesprogrammingbyreducingtheneedtobeconcernedwiththeexactorderofstatementexecution,sinceavariabledoesnothavetoberedeclared_orrestated,eachtimeitisusedinaprogramstatement.Manyoftheideasfromfunctionallanguageshavebecomekeypartsofmanymode

20、rnprocedurallanguages.Object-orientedlanguagesareoutgrowthsoffunctionallanguages.Inobject-orientedlanguages,thecodeusedtowritetheprogramandthedataprocessedbytheprogramaregroupedtogetherintounitscalledobjects.Objectsarefurthergroupedintoclasses,whichdefinetheattributesobjectsmusthave.Asimpleexampleof

21、aclassistheclassBook.ObjectswithinthisclassmightbeNovelandShortStory.Objectsalsohavecertainfunctionsassociatedwiththem,calledmethods.Thecomputeraccessesanobjectthroughtheuseofoneoftheobjectmethods.Themethodperformssomeactiontothedataintheobjectandreturnsthisvaluetothecomputer.Classesofobjectscanalso

22、befurthergroupedintohierarchies,inwhichobjectsofoneclasscaninheritmethodsfromanotherclass.Thestructureprovidedinobject-orientedlanguagesmakesthemveryusefulforcomplicatedprogrammingtasks.Logiclanguagesuselogicastheirmathematicalbase.Alogicprogramconsistsofsetsoffactsandif-thenrules,whichspecifyhowone

23、setoffactsmaybededucedfromothers,forexample:IfthestatementXistrue,thenthestatement丫isfalse.Intheexecutionofsuchaprogram,aninputstatementcanbelogicallydeducedfromotherstatementsintheprogram.Manyartificialintelligenceprogramsarewritteninsuchlanguages.IV. LanguageStructureandComponentsProgramminglangua

24、gesusespecifictypesofstatements,orinstructions,toprovidefunctionalstructuretotheprogram.Astatementinaprogramisabasicsentencethatexpressesasimpleidea-itspurposeistogivethecomputerabasicinstruction.Statementsdefinethetypesofdataallowed,howdataaretobemanipulated,andthewaysthatproceduresandfunctionswork

25、.Programmersusestatementstomanipulatecommoncomponentsofprogramminglanguages,suchasvariablesandmacros(mini-programswithinaprogram).Statementsknownasdatadeclarationsgivenamesandpropertiestoelementsofaprogramcalledvariables.Variablescanbeassigneddifferentvalueswithintheprogram.Thepropertiesvariablescan

26、havearecalledtypes,andtheyincludesuchthingsaswhatpossiblevaluesmightbesavedinthevariables,howmuchnumericalaccuracyistobeusedinthevalues,andhowonevariablemayrepresentacollectionofsimplervaluesinanorganizedfashion,suchasatableorarray.Inmanyprogramminglanguages,akeydatatypeisapointer.Variablesthatarepo

27、intersdonotthemselveshavevalues;instead,theyhaveinformationthatthecomputercanusetolocatesomeothervariablethatis,theypointtoanothervariable.Anexpressionisapieceofastatementthatdescribesaseriesofcomputationstobeperformedonsomeoftheprogram'svariables,suchasX+Y/Z,inwhichthevariablesareX,Y,andZandthe

28、computationsareadditionanddivision.Anassignmentstatementassignsavariableavaluederivedfromsomeexpression,whileconditionalstatementsspecifyexpressionstobetestedandthenusedtoselectwhichotherstatementsshouldbeexecutednext.Procedureandfunctionstatementsdefinecertainblocksofcodeasproceduresorfunctionsthat

29、canthenbereturnedtolaterintheprogram.Thesestatementsalsodefinethekindsofvariablesandparameterstheprogrammercanchooseandthetypeofvaluethatthecodewillreturnwhenanexpressionaccessestheprocedureorfunction.Manyprogramminglanguagesalsopermitminitranslationprogramscalledmacros.Macrostranslatesegmentsofcode

30、thathavebeenwritteninalanguagestructuredefinedbytheprogrammerintostatementsthattheprogramminglanguageunderstands.V. HistoryProgramminglanguagesdatebackalmosttotheinventionofthedigitalcomputerinthe1940s.Thefirstassemblylanguagesemergedinthelate1950swiththeintroductionofcommercialcomputers.Thefirstpro

31、cedurallanguagesweredevelopedinthelate1950stoearly1960s:FORTRAN,createdbyJohnBackus,andthenCOBOL,createdbyGraceHopperThefirstfunctionallanguagewasLISP,writtenbyJohnMcCarthy4inthelate1950s.Althoughheavilyupdated,allthreelanguagesarestillwidelyusedtoday.Inthelate1960s,thefirstobject-orientedlanguages,

32、suchasSIMULA,emerged.Logiclanguagesbecamewellknowninthemid1970swiththeintroductionofPROLOG6,alanguageusedtoprogramartificialintelligencesoftware.Duringthe1970s,procedurallanguagescontinuedtodevelopwithALGOL,BASIC,PASCAL,C,andAdaSMALLTALKwasahighlyinfluentialobject-orientedlanguagethatledtothemerging

33、ofobject-orientedandprocedurallanguagesinC+andmorerecentlyinJAVA10.Althoughpurelogiclanguageshavedeclinedinpopularity,variationshavebecomevitallyimportantintheformofrelationallanguagesformoderndatabases,suchasSQL.計(jì)算機(jī)程序一、引言計(jì)算機(jī)程序是指導(dǎo)計(jì)算機(jī)執(zhí)行某個(gè)功能或功能組合的一套指令。要使指令得到執(zhí)行,計(jì)算機(jī)必須執(zhí)行程序,也就是說,計(jì)算機(jī)要讀取程序,然后按準(zhǔn)確的順序?qū)嵤┏绦蛑芯幋a的步

34、驟,直至程序結(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ī)訪問存儲(chǔ)器、硬盤驅(qū)動(dòng)器、監(jiān)視器、鍵盤、打印機(jī)和調(diào)制解調(diào)器,以便使其他程序可以使用它們。操作系統(tǒng)的例子包括:DOS、Windows95、OS/2和UNIX。二、程序開發(fā)軟件設(shè)計(jì)者通過特殊的應(yīng)用程序來開發(fā)新程序,這些應(yīng)用程序常被稱作實(shí)用程序或開發(fā)程序。程序員使用稱作文本編輯器的另一種程序,來以稱作編程語言的特殊標(biāo)記編寫新程序。使用文本編輯器,程序員創(chuàng)建一個(gè)文本

35、文件,這個(gè)文本文件是一個(gè)有序指令表,也稱為程序源文件。構(gòu)成程序源文件的單個(gè)指令被稱為源代碼。在這個(gè)時(shí)候,一種特殊的應(yīng)用程序?qū)⒃创a翻譯成機(jī)器語言或目標(biāo)代碼一一操作系統(tǒng)將認(rèn)作真程序并能夠執(zhí)行的一種格式。將源代碼翻譯成目標(biāo)代碼的應(yīng)用程序有3種:編譯器、解釋器和匯編程序。這3種應(yīng)用程序在不同類型的編程語言上執(zhí)行不同的操作,但是它們都起到將編程語言翻譯成機(jī)器語言的相同目的。編譯器將使用FORTRAN、C和Pascal等高級編程語言編寫的文本文件一次性從源代碼翻譯成目標(biāo)代碼。這不同于BASIC等解釋執(zhí)行的語言所采取的方式,在解釋執(zhí)行的語言中程序是隨著每條指令的執(zhí)行而逐個(gè)語句地翻譯成目標(biāo)代碼的。解釋執(zhí)行的

36、語言的優(yōu)點(diǎn)是,它們可以立即開始執(zhí)行程序,而不需要等到所有的源代碼都得到編譯。對程序的更改也可以相當(dāng)快地作出,而無需等到重新編譯整個(gè)程序。解釋執(zhí)行的語言的缺點(diǎn)是,它們執(zhí)行起來慢,因?yàn)槊看芜\(yùn)行程序,都必須對整個(gè)程序一次一條指令地翻譯。另一方面,編譯執(zhí)行的語言只編譯一次,因此計(jì)算機(jī)執(zhí)行起來要比解釋執(zhí)行的語言快得多。由于這個(gè)原因,編譯執(zhí)行的語言更常使用,而且在專業(yè)和科學(xué)領(lǐng)域幾乎總是得到采用。另一種翻譯器是匯編程序,它被用于以匯編語言編寫的程序或程序組成部分。匯編語言也是一種編程語言,但它比其他類型的高級語言更接近于機(jī)器語言。在匯編語言中,一條語句通??梢苑g成機(jī)器語言的一條指令。今天,匯編語言很少用來

37、編寫整個(gè)程序,而是最經(jīng)常地采用于程序員需要直接控制計(jì)算機(jī)某個(gè)方面功能的場合。程序經(jīng)常被編寫作一套較小的程序段,每段代表整個(gè)應(yīng)用程序的某個(gè)方面。各段獨(dú)立編譯之后,一種被稱為連接程序的程序?qū)⑺芯幾g好的程序段組合成一個(gè)可以執(zhí)行的完整程序。程序很少有第一次能夠正確運(yùn)行的,所以一種被稱為調(diào)試程序的程序常被用來幫助查找被稱為程序錯(cuò)誤的問題。調(diào)試程序通常在運(yùn)行的程序中檢測到一個(gè)事件,并向程序員指出事件在程序代碼中的起源。最近出現(xiàn)的編程系統(tǒng),如Java,采取多種方法相結(jié)合的方式創(chuàng)建和執(zhí)行程序。編譯器取來Java源程序,并將其翻譯成中間形式。這樣的中間程序隨后通過因特網(wǎng)傳送給計(jì)算機(jī),而這些計(jì)算機(jī)里的解釋程序接

38、下來將中間程序作為應(yīng)用程序來執(zhí)行。三、程序元素大多數(shù)程序只是由少數(shù)幾種步驟構(gòu)成,這些步驟在整個(gè)程序中在不同的上下文和以不同的組合方式多次重復(fù)。最常見的步驟執(zhí)行某種計(jì)算,然后按照程序員指定的順序,進(jìn)入程序的下一個(gè)步驟。程序經(jīng)常需要多次重復(fù)不長的一系列步驟,例如,瀏覽游戲得分表,從中找出最高得分。這種重復(fù)的代碼序列稱為循環(huán)。計(jì)算機(jī)所具有的使其如此有用的能力之一,就是它們能夠作出條件判定,并根據(jù)正在處理的數(shù)據(jù)的值執(zhí)行不同的指令。if-then-else(如果一則一否則)語句通過測試某個(gè)數(shù)據(jù)段,然后根據(jù)結(jié)果從兩個(gè)指令序列中選出一個(gè),來執(zhí)行這個(gè)功能。這些選擇對象中的指令之一可能是一個(gè)goto語句,用以指

39、引計(jì)算機(jī)從程序的另一個(gè)部分選擇下一條指令。例如,一個(gè)程序可能比較兩個(gè)數(shù),并依據(jù)比較的結(jié)果而分支到程序的另一個(gè)部分:Ifxisgreaterthanythengotoinstruction#10elsecontinue程序經(jīng)常不止一次地使用特定的一系列步驟。這樣的一系列步驟可以組合成一個(gè)子例程,而子例程根據(jù)需要可在主程序的不同部分進(jìn)行調(diào)用或訪問。每次調(diào)用一個(gè)子例程,計(jì)算機(jī)都會(huì)記住它自己在該調(diào)用發(fā)生時(shí)處在程序的那個(gè)位置,以便在運(yùn)行完該子例程后還能夠回到那里。在每次調(diào)用之前,程序可以指定子例程使用不同的數(shù)據(jù),從而做到一個(gè)通用性很強(qiáng)的代碼段只編寫一次,而被以多種方式使用。大多數(shù)程序使用幾種不同的子例程。其中最常用的是函數(shù)、過程、庫程序、系統(tǒng)程序以及設(shè)備驅(qū)動(dòng)程序。函數(shù)是一種短子例程,用來計(jì)算某個(gè)值,如角的計(jì)算,而該值計(jì)算機(jī)僅用一條基本指令無法計(jì)算。過程執(zhí)行的是復(fù)雜一些的功能,如給一組名稱排序。庫程序是為許多不同的程序使用而編寫的子例程。系統(tǒng)程序和庫程序相似,但實(shí)際上用于操作系統(tǒng)。它們?yōu)閼?yīng)用程序提供某種服務(wù),如打印一行文字。設(shè)備驅(qū)動(dòng)程序是一種系統(tǒng)程序,它們加到操作系統(tǒng)中,以使計(jì)算機(jī)能夠與掃描儀、調(diào)制解調(diào)器或打印機(jī)等新設(shè)備進(jìn)行通信。設(shè)備驅(qū)動(dòng)程序常常具有可以直接作為應(yīng)用程序執(zhí)行的特征。這

溫馨提示

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

最新文檔

評論

0/150

提交評論