英文文献及翻译计算机程序Word文件下载.docx
《英文文献及翻译计算机程序Word文件下载.docx》由会员分享,可在线阅读,更多相关《英文文献及翻译计算机程序Word文件下载.docx(10页珍藏版)》请在冰点文库上搜索。
姓名:
刘峻霖班级:
通信143班学号:
2014101108
ComputerLanguageandProgramming
I.Introduction
Programminglanguages,incomputerscience,aretheartificiallanguagesusedtowriteasequenceofinstructions(acomputerprogram)thatcanberunbyacomputer.Similartonaturallanguages,suchasEnglish,programminglanguageshaveavocabulary,grammar,andsyntax.However,naturallanguagesarenotsuitedforprogrammingcomputersbecausetheyareambiguous,meaningthattheirvocabularyandgrammaticalstructuremaybeinterpretedinmultipleways.Thelanguagesusedtoprogramcomputersmusthavesimplelogicalstructures,andtherulesfortheirgrammar,spelling,andpunctuationmustbeprecise.
Programminglanguagesvarygreatlyintheirsophisticationandintheirdegreeofversatility.Someprogramminglanguagesarewrittentoaddressaparticularkindofcomputingproblemorforuseonaparticularmodelofcomputersystem.Forinstance,programminglanguagessuchasFORTRANandCOBOLwerewrittentosolvecertaingeneraltypesofprogrammingproblems—FORTRANforscientificapplications,andCOBOLforbusinessapplications.Althoughtheselanguagesweredesignedtoaddressspecificcategoriesofcomputerproblems,theyarehighlyportable,meaningthattheymaybeusedtoprogrammanytypesofcomputers.Otherlanguages,suchasmachinelanguages,aredesignedtobeusedbyonespecificmodelofcomputersystem,orevenbyonespecificcomputerincertainresearchapplications.Themostcommonlyusedprogramminglanguagesarehighlyportableandcanbeusedtoeffectivelysolvediversetypesofcomputingproblems.LanguageslikeC,PASCALandBASICfallintothiscategory.
II.LanguageTypes
Programminglanguagescanbeclassifiedaseitherlow-levellanguagesorhigh-levellanguages.Low-levelprogramminglanguages,ormachinelanguages,arethemostbasictypeofprogramminglanguagesandcanbeunderstooddirectlybyacomputer.Machinelanguagesdifferdependingonthemanufacturerandmodelofcomputer.High-levellanguagesareprogramminglanguagesthatmustfirstbetranslatedintoamachinelanguagebeforetheycanbeunderstoodandprocessedbyacomputer.Examplesofhigh-levellanguagesareC,C++,PASCAL,andFORTRAN.Assemblylanguagesareintermediatelanguagesthatareveryclosetomachinelanguagesanddonothavetheleveloflinguisticsophisticationexhibitedbyotherhigh-levellanguages,butmuststillbetranslatedintomachinelanguage.
1.MachineLanguages
Inmachinelanguages,instructionsarewrittenassequencesof1sand0s,calledbits,thatacomputercanunderstanddirectly.Aninstructioninmachinelanguagegenerallytellsthecomputerfourthings:
(1)wheretofindoneortwonumbersorsimplepiecesofdatainthemaincomputermemory(RandomAccessMemory,orRAM),
(2)asimpleoperationtoperform,suchasaddingthetwonumberstogether,(3)whereinthemainmemorytoputtheresultofthissimpleoperation,and(4)wheretofindthenextinstructiontoperform.Whileallexecutableprogramsareeventuallyreadbythecomputerinmachinelanguage,theyarenotallprogrammedinmachinelanguage.Itisextremelydifficulttoprogramdirectlyinmachinelanguagebecausetheinstructionsaresequencesof1sand0s.Atypicalinstructioninamachinelanguagemightread1001011001011andmeanaddthecontentsofstorageregisterAtothecontentsofstorageregisterB.
2.High-LevelLanguages
High-levellanguagesarerelativelysophisticatedsetsofstatementsutilizingwordsandsyntaxfromhumanlanguage.Theyaremoresimilartonormalhumanlanguagesthanassemblyormachinelanguagesandarethereforeeasiertouseforwritingcomplicatedprograms.Theseprogramminglanguagesallowlargerandmorecomplicatedprogramstobedevelopedfaster.However,high-levellanguagesmustbetranslatedintomachinelanguagebyanotherprogramcalledacompilerbeforeacomputercanunderstandthem.Forthisreason,programswritteninahigh-levellanguagemaytakelongertoexecuteanduseupmorememorythanprogramswritteninanassemblylanguage.
3.AssemblyLanguages
Computerprogrammersuseassemblylanguagestomakemachine-languageprogramseasiertowrite.Inanassemblylanguage,eachstatementcorrespondsroughlytoonemachinelanguageinstruction.Anassemblylanguagestatementiscomposedwiththeaidofeasytoremembercommands.ThecommandtoaddthecontentsofthestorageregisterAtothecontentsofstorageregisterBmightbewrittenADDB,Ainatypicalassemblylanguagestatement.Assemblylanguagessharecertainfeatureswithmachinelanguages.Forinstance,itispossibletomanipulatespecificbitsinbothassemblyandmachinelanguages.Programmersuseassembly
languageswhenitisimportanttominimizethetimeittakestorunaprogram,becausethetranslationfromassemblylanguagetomachinelanguageisrelativelysimple.Assemblylanguagesarealsousedwhensomepartofthecomputerhastobecontrolleddirectly,suchasindividualdotsonamonitorortheflowofindividualcharacterstoaprinter.
III.ClassificationofHigh-LevelLanguages
High-levellanguagesarecommonlyclassifiedasprocedure-oriented,functional,object-oriented,orlogiclanguages.Themostcommonhigh-levellanguagestodayareprocedure-orientedlanguages.Intheselanguages,oneormorerelatedblocksofstatementsthatperformsomecompletefunctionaregroupedtogetherintoaprogrammodule,orprocedure,andgivenanamesuchas“procedureA.”Ifthesamesequenceofoperationsisneededelsewhereintheprogram,asimplestatementcanbeusedtoreferbacktotheprocedure.Inessence,aprocedureisjusta
mini-program.Alargeprogramcanbeconstructedbygroupingtogetherproceduresthatperformdifferenttasks.Procedurallanguagesallowprogramstobeshorterandeasierforthecomputertoread,buttheyrequiretheprogrammertodesigneachproceduretobegeneralenoughtobeused
indifferentsituations.Functionallanguagestreatprocedureslikemathematicalfunctionsandallowthemtobeprocessedlikeanyotherdatainaprogram.Thisallowsamuchhigherandmorerigorouslevelofprogramconstruction.Functionallanguagesalsoallowvariables—symbolsfordatathatcanbespecifiedandchangedbytheuserastheprogramisrunning—tobegivenvaluesonlyonce.Thissimplifiesprogrammingbyreducingtheneedtobeconcernedwiththeexactorderofstatementexecution,sinceavariabledoesnothavetoberedeclared,orrestated,eachtimeitisusedinaprogramstatement.Manyoftheideasfromfunctionallanguageshavebecomekeypartsofmanymodernprocedurallanguages.Object-orientedlanguagesareoutgrowthsoffunctionallanguages.Inobject-orientedlanguages,thecodeusedtowritetheprogramandthedataprocessedbytheprogramaregroupedtogetherintounitscalledobjects.Objectsarefurthergroupedintoclasses,whichdefinetheattributesobjectsmusthave.AsimpleexampleofaclassistheclassBook.ObjectswithinthisclassmightbeNovelandShortStory.Objectsalsohavecertainfunctionsassociatedwiththem,calledmethods.Thecomputeraccessesanobjectthroughtheuseofoneoftheobject’smethods.Themethodperformssomeactiontothedataintheobjectandreturnsthisvaluetothecomputer.
Classesofobjectscanalsobefurthergroupedintohierarchies,inwhichobjectsofoneclasscaninheritmethodsfromanotherclass.Thestructureprovidedinobject-orientedlanguagesmakesthemveryusefulforcomplicatedprogrammingtasks.Logiclanguagesuselogicastheirmathematicalbase.Alogicprogramconsistsofsetsoffactsandif-thenrules,whichspecifyhowonesetoffactsmaybededucedfromothers,forexample:
IfthestatementXistrue,thenthestatementYisfalse.Intheexecutionofsuchaprogram,aninputstatementcanbelogicallydeducedfromotherstatementsintheprogram.Manyartificialintelligenceprogramsarewritteninsuchlanguages.
IV.LanguageStructureandComponents
Programminglanguagesusespecifictypesofstatements,orinstructions,toprovidefunctionalstructuretotheprogram.Astatementinaprogramisabasicsentencethatexpressesasimpleidea—itspurposeistogivethecomputerabasicinstruction.Statementsdefinethetypesofdataallowed,howdataaretobemanipulated,andthewaysthatproceduresandfunctionswork.Programmersusestatementstomanipulatecommoncomponentsofprogramminglanguages,suchasvariablesandmacros(mini-programswithinaprogram).Statementsknownasdatadeclarationsgivenamesandpropertiestoelementsofaprogramcalledvariables.Variablescanbeassigneddifferentvalueswithintheprogram.Thepropertiesvariablescanhavearecalledtypes,andtheyincludesuchthingsaswhatpossiblevaluesmightbesavedinthevariables,howmuchnumericalaccuracyistobeusedinthevalues,andhowonevariablemayrepresentacollectionofsimplervaluesinanorganizedfashion,suchasatableorarray.Inmanyprogramminglanguages,akeydatatypeisapointer.Variablesthatarepointersdonotthemselveshavevalues;
instead,theyhaveinformationthatthecomputercanusetolocatesomeothervariable—thatis,theypointtoanothervariable.Anexpressionisapieceofastatementthatdescribesaseriesofcomputationstobeperformedonsomeoftheprogram’svariables,suchasX+Y/Z,inwhichthevariablesareX,Y,andZandthecomputationsareadditionanddivision.Anassignmentstatementassignsavariableavaluederivedfromsomeexpression,whileconditionalstatementsspecifyexpressionstobetestedandthenusedtoselectwhichotherstatementsshouldbeexecutednext.
Procedureandfunctionstatementsdefinec