计算机专业英语3.docx

上传人:b****1 文档编号:1901161 上传时间:2023-05-02 格式:DOCX 页数:5 大小:18.46KB
下载 相关 举报
计算机专业英语3.docx_第1页
第1页 / 共5页
计算机专业英语3.docx_第2页
第2页 / 共5页
计算机专业英语3.docx_第3页
第3页 / 共5页
计算机专业英语3.docx_第4页
第4页 / 共5页
计算机专业英语3.docx_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

计算机专业英语3.docx

《计算机专业英语3.docx》由会员分享,可在线阅读,更多相关《计算机专业英语3.docx(5页珍藏版)》请在冰点文库上搜索。

计算机专业英语3.docx

计算机专业英语3

Unit3ComputerLanguageandProgramming

SectionAProgrammingLanguage

I.Introduction

Programminglanguages,incomputerscience,aretheartificiallanguagesusedtowriteasequenceofinstructions(acomputerprogram)thatcanberunbyacomputer.Similartonaturallanguages,suchasEnglish,programminglanguageshaveavocabulary,grammar,andsyntax.However,naturallanguagesarenotsuitedforprogrammingcomputersbecausetheyareambiguous,meaningthattheirvocabularyandgrammaticalstructuremaybeinterpretedinmultipleways.Thelanguagesusedtoprogramcomputersmusthavesimplelogicalstructures,andtherulesfortheirgrammar,spelling,andpunctuationmustbeprecise.

Programminglanguagesvarygreatlyintheirsophisticationandintheirdegreeofversatility.Someprogramminglanguagesarewrittentoaddress(处理)aparticularkindofcomputingproblemorforuseonaparticularmodelofcomputersystem.Forinstance,programminglanguagessuchasFORTRAN1andCOBOL2werewrittentosolvecertaingeneraltypesofprogrammingproblems—FORTRANforscientificapplications,andCOBOLforbusinessapplications.Althoughtheselanguagesweredesigntoaddressspecificcategoriesofcomputerproblems,theyarehighlyportable(可移植),meaningthattheymaybeusedtoprogrammanytypesofcomputers.Otherlanguages,suchasmachinelanguages,aredesignedtobeusedbyonespecificmodelofcomputersystem,orevenbyonespecificcomputerincertainresearchapplications.Themostcommonlyusedprogramminglanguagesarehighlyportableandcanbeusedtoeffectivelysolvediversetypesofcomputingproblems.LanguageslikeC,PASCALandBASICfallinto(属于)thiscategory.

II.LanguageTypes

Programminglanguagescanbeclassifiedaseitherlow-levellanguagesorhigh-levellanguages.Low-levelprogramminglanguages,ormachinelanguages,arethemostbasictypeofprogramminglanguagesandcanbeunderstooddirectlybyacomputer.Machinelanguagesdifferdependingonthemanufacturerandmodelofcomputer.High-levellanguagesareprogramminglanguagesthatmustfirstbetranslatedintoamachinelanguagebeforetheycanbeunderstoodandprocessedbyacomputer.Examplesofhigh-levellanguagesareC,C++6,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-levellanguagemaytakelongertoexecuteanduseup(用完)morememorythanprogramswritteninanassemblylanguage.

3.AssemblyLanguages

Computerprogrammersuseassemblylanguagestomakemachine-languageprogramseasiertowrite.Inanassemblylanguage,eachstatementcorrespondsroughlytoonemachinelanguageinstruction.Anassemblylanguagestatementiscomposedwiththeaidof(借助于,帮助)easytoremembercommands.ThecommandtoaddthecontentsofstorageregisterAtothecontentsofstorageregisterBmightbewrittenADDB,Ainatypicalassemblylanguagestatement.Assemblylanguagessharecertainfeatureswithmachinelanguages.Forinstance,itispossibletomanipulatespecificbitsinbothassemblyandmachinelanguages.Programmersuseassemblylanguageswhenitisimportanttominimizethetimeittakestorunaprogram,becausethetranslationfromassemblylanguagetomachinelanguageisrelativelysimple.Assemblylanguagesarealsousedwhensomepartofthecomputerhastobecontrolleddirectly,suchasindividualdotsonamonitorortheflowofindividualcharacterstoaprinter.

III.ClassificationofHigh-LevelLanguages

High-levellanguagesarecommonlyclassifiedasprocedure-oriented,functional,object-oriented,orlogiclanguages.Themostcommonhigh-levellanguagestodayareprocedure-orientedlanguages.Inlanguages,oneormorerelatedblocksofstatementsthatperformsomecompletefunctionaregroupedtogetherintoaprogrammodule,orprocedure,andgivenanamesuchas"procedureA."Ifthesamesequenceofoperationsisneededelsewhereintheprogram,asimplestatementcanbeusedtoreferbacktotheprocedure.Inessence,aprocedureisjustamini-program.Alargeprogramcanbeconstructedbygroupingtogetherproceduresthatperformdifferenttasks.Procedurallanguagesallowprogramstobeshorterandeasierforthecomputertoread,buttheyrequiretheprogrammertodesigneachproceduretobegeneralenoughtobeuseindifferentsituations.

Functionallanguagestreatprocedureslikemathematicalfunctionandallowthemtobeprocessedlikeanyotherdatainaprogram.Thisallowsamuchhigherandmorerigorouslevelofprogramconstruction,Functionallanguagesalsoallowvariables—symbolsfordatathatcanbespecifiedandchangedbytheuserastheprogramisrunning—tobegivenvaluesonlyonce.Thissimplifiesprogrammingbyreducingtheneedtobeconcernedwiththeexactorderofstatementexecution,sinceavariabledoesnothavetoberedeclared,orrestated,eachtimeitisusedinaprogramstatement.Manyoftheideasfromfunctionallanguageshavebecomekey|partsofmanymodemprocedurallanguages.

Object-orientedlanguagesareoutgrowthsoffunctionallanguages.Inobject-orientedlanguages,thecodeusedtowritetheprogramandthedataprocessedbytheprogramaregroupedtogetherintounitscalledobjects,Objectsarefurthergroupedintoclasses,whichdefinetheattributesobjectsmusthave.AsimpleexampleofaclassistheclassBook.ObjectswithinthisclassmightbeNovelandShortStory.Objectsalsohavecertainfunctionsassociatedwiththem,calledmethods.Thecomputeraccessesanobjectthroughtheuseofoneoftheobject'smethods.Themethodperformssomeactiontothedataintheobjectandreturnsthisvaluetothecomputer.Classesofobjectscanalsobefurthergroupedintohierarchies,inwhichobjectsofoneclasscaninheritmethodsfromanotherclass.Thestructureprovidedinobject-orientedlanguagesmakesthemveryusefulforcomplicatedprogrammingtasks.

Logiclanguagesuselogicastheirmathematicalbase.Alogicprogramconsistsofsetsoffactsandif-thenrules,whichspecifyhowonesetoffactsmaybededucedfrom(推断)others,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.Anassignmentstatementassignsavariableavaluederivedfrom(得自)someexpression,whileconditionalstatementsspecifyexpressionstobetestedandthenusedtoselectwhichotherstatementsshouldbeexecutednext.

Procedureandfunctionstatementsdefinecertainblocksofcodeasproceduresorfunct

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2