付费下载
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、姓名:刘峻霖班级:通信143班学号: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.计算机程序一、引言计算机程序是指导计算机执行某个功能或功能组合的一套指令。要使指令得到执行,计算机必须执行程序,也就是说,计算机要读取程序,然后按准确的顺序实施程序中编码的步
34、骤,直至程序结束。一个程序可多次执行,而且每次用户输给计算机的选项和数据不同,就有可能得到不同的结果。程序可分为两大类:应用程序和操作系统。应用程序直接为用户执行某项功能,如字处理或玩游戏。操作系统管理计算机和与之相连的各种资源和设备,如随机访问存储器、硬盘驱动器、监视器、键盘、打印机和调制解调器,以便使其他程序可以使用它们。操作系统的例子包括:DOS、Windows95、OS/2和UNIX。二、程序开发软件设计者通过特殊的应用程序来开发新程序,这些应用程序常被称作实用程序或开发程序。程序员使用称作文本编辑器的另一种程序,来以称作编程语言的特殊标记编写新程序。使用文本编辑器,程序员创建一个文本
35、文件,这个文本文件是一个有序指令表,也称为程序源文件。构成程序源文件的单个指令被称为源代码。在这个时候,一种特殊的应用程序将源代码翻译成机器语言或目标代码一一操作系统将认作真程序并能够执行的一种格式。将源代码翻译成目标代码的应用程序有3种:编译器、解释器和汇编程序。这3种应用程序在不同类型的编程语言上执行不同的操作,但是它们都起到将编程语言翻译成机器语言的相同目的。编译器将使用FORTRAN、C和Pascal等高级编程语言编写的文本文件一次性从源代码翻译成目标代码。这不同于BASIC等解释执行的语言所采取的方式,在解释执行的语言中程序是随着每条指令的执行而逐个语句地翻译成目标代码的。解释执行的
36、语言的优点是,它们可以立即开始执行程序,而不需要等到所有的源代码都得到编译。对程序的更改也可以相当快地作出,而无需等到重新编译整个程序。解释执行的语言的缺点是,它们执行起来慢,因为每次运行程序,都必须对整个程序一次一条指令地翻译。另一方面,编译执行的语言只编译一次,因此计算机执行起来要比解释执行的语言快得多。由于这个原因,编译执行的语言更常使用,而且在专业和科学领域几乎总是得到采用。另一种翻译器是汇编程序,它被用于以汇编语言编写的程序或程序组成部分。汇编语言也是一种编程语言,但它比其他类型的高级语言更接近于机器语言。在汇编语言中,一条语句通常可以翻译成机器语言的一条指令。今天,汇编语言很少用来
37、编写整个程序,而是最经常地采用于程序员需要直接控制计算机某个方面功能的场合。程序经常被编写作一套较小的程序段,每段代表整个应用程序的某个方面。各段独立编译之后,一种被称为连接程序的程序将所有编译好的程序段组合成一个可以执行的完整程序。程序很少有第一次能够正确运行的,所以一种被称为调试程序的程序常被用来帮助查找被称为程序错误的问题。调试程序通常在运行的程序中检测到一个事件,并向程序员指出事件在程序代码中的起源。最近出现的编程系统,如Java,采取多种方法相结合的方式创建和执行程序。编译器取来Java源程序,并将其翻译成中间形式。这样的中间程序随后通过因特网传送给计算机,而这些计算机里的解释程序接
38、下来将中间程序作为应用程序来执行。三、程序元素大多数程序只是由少数几种步骤构成,这些步骤在整个程序中在不同的上下文和以不同的组合方式多次重复。最常见的步骤执行某种计算,然后按照程序员指定的顺序,进入程序的下一个步骤。程序经常需要多次重复不长的一系列步骤,例如,浏览游戏得分表,从中找出最高得分。这种重复的代码序列称为循环。计算机所具有的使其如此有用的能力之一,就是它们能够作出条件判定,并根据正在处理的数据的值执行不同的指令。if-then-else(如果一则一否则)语句通过测试某个数据段,然后根据结果从两个指令序列中选出一个,来执行这个功能。这些选择对象中的指令之一可能是一个goto语句,用以指
39、引计算机从程序的另一个部分选择下一条指令。例如,一个程序可能比较两个数,并依据比较的结果而分支到程序的另一个部分:Ifxisgreaterthanythengotoinstruction#10elsecontinue程序经常不止一次地使用特定的一系列步骤。这样的一系列步骤可以组合成一个子例程,而子例程根据需要可在主程序的不同部分进行调用或访问。每次调用一个子例程,计算机都会记住它自己在该调用发生时处在程序的那个位置,以便在运行完该子例程后还能够回到那里。在每次调用之前,程序可以指定子例程使用不同的数据,从而做到一个通用性很强的代码段只编写一次,而被以多种方式使用。大多数程序使用几种不同的子例程。其中最常用的是函数、过程、库程序、系统程序以及设备驱动程序。函数是一种短子例程,用来计算某个值,如角的计算,而该值计算机仅用一条基本指令无法计算。过程执行的是复杂一些的功能,如给一组名称排序。库程序是为许多不同的程序使用而编写的子例程。系统程序和库程序相似,但实际上用于操作系统。它们为应用程序提供某种服务,如打印一行文字。设备驱动程序是一种系统程序,它们加到操作系统中,以使计算机能够与扫描仪、调制解调器或打印机等新设备进行通信。设备驱动程序常常具有可以直接作为应用程序执行的特征。这
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025江西省华忆电子工业中等专业学校工作人员招聘考试试题
- 2025江苏城市职业学院常州办学点工作人员招聘考试试题
- 智能客服中心建设可行性分析:2025年技术引领沉浸式体验
- 绿植在小学美术教室空气质量提升中的应用效果研究教学研究课题报告
- 幼儿园教师观察记录能力培训效果研究-基于幼儿园教师专业技能培训数据分析深度研究
- 危大工程专项施工方案
- 新能源汽车电池回收再利用项目在2025年的市场拓展可行性分析
- 基于同伴互评的初中英语写作教学策略创新与实践效果分析教学研究课题报告
- 2026年通信行业6G技术展望报告
- 管理人员工作总结15篇
- 2026贵州省住房资金管理中心招聘工作人员1人备考题库含答案详解(考试直接用)
- 2026储能入市背景下的投资测算工具设计逻辑深度研究报告
- 2026四川省阿坝州州级事业单位考试调动37人重点基础提升(共500题)附带答案详解
- 2026湖北神农架林区公安局招聘辅警22人笔试参考题库及答案解析
- JJG 693-2011可燃气体检测报警器
- 光伏组件失效模式介绍课件
- 《过松源晨炊漆公店》PPT
- 市场调查与统计知到章节答案智慧树2023年北京财贸职业学院
- DB42T 1144-2016燃气用不锈钢波纹软管安装及验收规范
- GB/T 14048.7-2016低压开关设备和控制设备第7-1部分:辅助器件铜导体的接线端子排
- 《极地地区》第2课时示范公开课教学课件【地理人教七年级下册】
评论
0/150
提交评论