版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、姓名:刘峻霖班级:通信143 班学号Computer Language and ProgrammingI. IntroductionProgramming languages, in computer science, are the artificial languages used to write a sequence ofinstructions (a computer program) that can be run by a computer. Similar tonatural languages, suchasEnglish,programminglanguageshaveav
2、ocabulary,grammar, andsyntax.However,naturallanguages are not suited for programming computers because they are ambiguous,meaning that theirvocabularyandgrammaticalstructuremaybe interpretedinmultipleways.Thelanguagesused toprogramcomputersmusthave simplelogicalstructures,andtherulesfortheirgrammar,
3、spelling,and punctuation must be precise.Programming languages vary greatly in their sophistication and in their degree of versatility. Someprogramming languages are written to address a particular kind of computing problem or for use on aparticular model of computer system. For instance, programmin
4、g languages such as FORTRANandCOBOLwerewrittento solvecertaingeneraltypesofprogrammingproblems FORTRANforscientificapplications,andCOBOLforbusinessapplications.Althoughtheselanguagesweredesigned to address specific categories of computer problems, they are highly portable, meaning thatthey may be us
5、ed 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 computerincertainresearchapplications.Themostcommonlyusedprogrammingl anguagesarehighlyportable and can be used to effectively s
6、olve diverse types of computing problems. Languages like C,PASCAL and BASIC fall into this category.II. Language TypesProgramminglanguagescanbeclassifiedas eitherlow-levellanguagesorhigh-levellanguages.Low-level programminglanguages, ormachinelanguages, arethemostbasictypeof programminglanguages and
7、 can be understood directly by a computer. Machine languages differ depending on themanufacturerand modelof computer.High-levellanguagesare programminglanguagesthatmustfirstbe translatedintoa machinelanguagebeforethey canbeunderstoodandprocessedby acomputer.Examplesofhigh-levellanguagesare C,C+, PAS
8、CAL,and FORTRAN.Assemblylanguages are intermediatelanguages that are very close to machine languages and do not have thelevel of linguistic sophistication exhibited by other high-level languages, but must still be translatedinto machine language.1. Machine LanguagesIn machine languages, instructions
9、 are written as sequences of 1s and 0s, called bits, that a computercan 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 mem ory (Random Access Memory, or RAM), (2) a si
10、mple operation to perform, such as adding the twonumbers together, (3)where in the mainmemory 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 bythe computer in machine language, they are not all progr
11、ammed in machine language. It is extremelydifficult 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 contentsof storage register A to the contents of storage register B.
12、2. High-Level LanguagesHigh-level languages are relatively sophisticated sets of statements utilizing words and syntax fromhumanlanguage.Theyaremoresimilarto normalhumanlanguagesthan assemblyor machinelanguages and arethereforeeasier touse forwritingcomplicatedprograms.Theseprogramminglanguages allo
13、w larger and more complicated programs to be developed faster. However, high-levellanguages must be translated into machine language by another program called a compiler before acomputer can understand them. For this reason, programs written in a high-level language may takelonger to execute and use
14、 up more memory than programs written in an assembly language.3. Assembly LanguagesComputer programmers use assembly languages to make machine-language programs easier to write.In an assembly language, each statement corresponds roughly to onemachine language instruction.An assemblylanguagestatement
15、is composedwiththe aidofeasy toremember commands.Thecommand to add the contents of the storage register A to the contents of storage register B might bewrittenADDB,Aina typicalassemblylanguagestatement.Assembly languagessharecertainfeatureswithmachinelanguages.Forinstance,itispossibletomanipulatespe
16、cificbitsinbothassembly and machine languages. Programmers use assemblylanguages 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 usedwhen some part of the compute
17、r has to be controlled directly, such as individual dots on a monitor orthe flow of individual characters to a printer.III. Classification of High-Level LanguagesHigh-level languages are commonly classified as procedure-oriented, functional, object-oriented, orlogic languages. The most common high-l
18、evel languages today are procedure-oriented languages. Inthese languages, one ormore related blocks of statements that perform some complete function aregrouped together into a program module, or procedure, and given a name such as“ procedure A. ”the same sequence of operations is needed elsewhere i
19、n the program, a simple statement can be usedto refer back to the procedure. In essence, a procedure is just amini-program.Alarge programcan be constructedbygroupingtogetherproceduresthat performdifferent tasks.Procedural languages allow programs to be shorter and easier for the computer toread, but
20、 they require the programmer to design each procedure to be general enough to be usedin different situations. Functional languages treat procedures like mathematical functions and allowthemto be processedlikeany otherdataina program.Thisallowsamuchhigherandmorerigorous level of program construction.
21、 Functional languages also allow variables symbols for datathatcan be specifiedand changedby the useras the programisrunning tobe givenvaluesonlyonce. Thissimplifiesprogramming byreducingthe need to be concernedwith the exact order ofstatement execution, since a variable does not have to be redeclar
22、ed , or restated, each time it is usedin a program statement. Many of the ideas from functional languages have become key parts of manymodern procedural languages. Object-oriented languages are outgrowths of functional languages. Inobject-oriented languages, the code used to write the program and th
23、e data processed by the programare grouped together into units called objects. Objects are further grouped into classes, which definethe attributes objects must have. A simple example of a class is the class Book. Objects within thisclassmightbeNovelandShortStory.Objectsalsohavecertainfunctionsassoc
24、iatedwiththem,called methods. The computer accesses an object through the use of one of the object s methods.method performs some action to the data in the object and returns this value to thecomputer.Classes ofobjectscan alsobe furthergroupedintohierarchies,in whichobjects ofone class caninherit me
25、thods from another class. The structure provided in object-oriented languages makes themveryusefulforcomplicatedprogrammingtasks. Logiclanguagesuselogicastheirmathematicalbase. A logic program consists of sets of facts and if-then rules, which specify how one set of factsmay be deduced from others,
26、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 statementsin the program. Many artificial intelligence programs are written in such languages.IV. Language Structure and ComponentsProgra
27、mminglanguagesusespecifictypesof statements,orinstructions,toprovide functionalstructuretothe program.Astatementinaprogramisa basicsentencethatexpressesasimpleidea itspurposeistogivethecomputera basicinstruction.Statementsdefinethe types ofdataallowed,howdataaretobe manipulated,andthewaysthatprocedu
28、resandfunctionswork.Programmers use statements to manipulate common components of programming languages, such asvariables and macros (mini-programs within a program). Statements known as data declarations givenames and properties to elements of a program called variables. Variables can be assigned d
29、ifferentvalues within the program. The properties variables can have are called types, and they include suchthings as what possible values might be saved in the variables, howmuch numerical accuracy is tobe used in the values,andhowonevariablemayrepresenta collectionofsimplervaluesinanorganizedfashi
30、on,suchas a tableorarray.In manyprogramminglanguages,a key datatypeis apointer.Variablesthatare pointersdonotthemselveshavevalues;instead,theyhaveinformationthat the computer can use to locate some other variable that is, they point to another variable. Anexpression is a piece of a statement that de
31、scribes a series of computations to be performed on someof the program svariables,such asX+Y/Z,inwhichthevariablesareX,Y,andZandthecomputations are addition and division. An assignment statement assigns a variable a value derivedfrom some expression, while conditional statements specify expressions
32、to be tested and then used toselect which other statements should be executed next.Procedure and function statements define certain blocks of code as procedures or functions that canthen bereturnedtolaterintheprogram. Thesestatementsalsodefinethekindsof variablesandparameterstheprogrammercan choose
33、and the typeofvaluethatthe codewillreturnwhenanexpressionaccessestheprocedureorfunction.Manyprogramminglanguagesalsopermitminitranslationprogramscalledmacros.Macrostranslatesegmentsofcodethathavebeenwritteninalanguagestructuredefinedbytheprogrammerintostatementsthattheprogramminglanguageunderstands.
34、V. HistoryProgramming languages date back almost to the invention of the digital computer in the 1940s. Thefirst 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
35、 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 stillwidely used today. In the late 1960s, the first object-oriented languages, such as SIMULA, emerged.Logic
36、 languages became well known in the mid 1970swith the introductionof PROLOG6, alanguage usedto programartificialintelligence software.Duringthe 1970s, procedural languagescontinuedtodevelopwithALGOL,BASIC,PASCAL,C,and A d a SMALLTALK was a highly influential object-oriented language that led to the
37、merging ofobject-oriented andprocedural languages in C+and morerecently in JAVA10.Althoughpurelogic languages have declined in popularity, variations have become vitally important in the form ofrelational languages for modern databases, such as SQL.计算机程序一、引言计算机程序是指导计算机执行某个功能或功能组合的一套指令。要使指令得到执行,计算机必须
38、执行程序,也就是说,计算机要读取程序,然后按准确的顺序实施程序中编码的步骤,直至程序结束。一个程序可多次执行,而且每次用户输给计算机的选项和数据不同,就有可能得到不同的结果。程序可分为两大类:应用程序和操作系统。应用程序直接为用户执行某项功能,如字处理或玩游戏。操作系统管理计算机和与之相连的各种资源和设备,如随机访问存储器、硬盘驱动器、监视器、键盘、打印机和调制解调器,以便使其他程序可以使用它们。操作系统的例子包括: DOS 、 Windows 95、 OS/2 和 UNIX 。二、程序开发软件设计者通过特殊的应用程序来开发新程序,这些应用程序常被称作实用程序或开发程序。程序员使用称作文本编辑
39、器的另一种程序,来以称作编程语言的特殊标记编写新程序。使用文本编辑器,程序员创建一个文本文件,这个文本文件是一个有序指令表,也称为程序源文件。构成程序源文件的单个指令被称为源代码。在这个时候,一种特殊的应用程序将源代码翻译成机器语言或目标代码 操作系统将认作真程序并能够执行的一种格式。将源代码翻译成目标代码的应用程序有3 种:编译器、解释器和汇编程序。这3 种应用程序在不同类型的编程语言上执行不同的操作,但是它们都起到将编程语言翻译成机器语言的相同目的。编译器将使用FORTRAN、 C 和 Pascal 等高级编程语言编写的文本文件一次性从源代码翻译成目标代码。这不同于BASIC等解释执行的语
40、言所采取的方式,在解释执行的语言中程序是随着每条指令的执行而逐个语句地翻译成目标代码的。解释执行的语言的优点是,它们可以立即开始执行程序,而不需要等到所有的源代码都得到编译。对程序的更改也可以相当快地作出,而无需等到重新编译整个程序。解释执行的语言的缺点是,它们执行起来慢,因为每次运行程序,都必须对整个程序一次一条指令地翻译。另一方面,编译执行的语言只编译一次,因此计算机执行起来要比解释执行的语言快得多。由于这个原因,编译执行的语言更常使用,而且在专业和科学领域几乎总是得到采用。另一种翻译器是汇编程序,它被用于以汇编语 言编写的程序或程序组成部分。汇编语言也是一种编程语言,但它比其他类型的高级
41、语言更接近于机器语言。在汇编语言中,一条语句通常可以翻译成机器语言的一条指令。今天,汇编语言很少用来编写整个程序,而是最经常地采用于程序员需要直接控制计算机某个方面功能的场合。程序经常被编写作一套较小的程序段,每段代表整个应用程序的某个方面。各段独立编译之后,一种被称为连接程序的程序将所有编译好的程序段组合成一个可以执行的完整程序。程序很少有第一次能够正确运行的,所以一种被称为调试程序的程序常被用来帮助查找被称为程序错误的问题。调试程序通常在运行的程序中检测到一个事件,并向程序员指出事件在程序代码中的起源。最近出现的编程系统,如Java ,采取多种方法相结合的方式创建和执行程序。编译器取来Ja
42、va 源程序,并将其翻译成中间形式。这样的中间程序随后通过因特网传送给计算机,而这些计算机里的解释程序接下来将中间程序作为应用程序来执行。三、程序元素大多数程序只是由少数几种步骤构成,这些步骤在整个程序中在不同的上下文和以不同的组合方式多次重复。最常见的步骤执行某种计算,然后按照程序员指定的顺序,进入程序的下一个步骤。程序经常需要多次重复不长的一系列步骤,例如,浏览游戏得分表,从中找出最高得分。这种重复的代码序列称为循环。计算机所具有的使其如此有用的能力之一,就是它们能够作出条件判定,并根据正在处理的数据的值执行不同的指令。if-then-else(如果则否则)语句通过测试某个数据段,然后根据
43、结果从两个指令序列中选出一个,来执行这个功能。这些选择对象中的指令之一可能是一个 goto 语句,用以指引计算机从程序的另一个部分选择下一条指令。例如,一个程序可能比较两个数,并依据比较的结果而分支到程序的另一个部分:If x is greater than ythengoto instruction #10else continue程序经常不止一次地使用特定的一系列步骤。这样的一系列步骤可以组合成一个子例程,而子例程根据需要可在主程序的不同部分进行调用或访问。每次调用一个子例程,计算机都会记住它自己在该调用发生时处在程序的那个位置,以便在运行完该子例程后还能够回到那里。在每次调用之前,程序可以指定子例程使用不同的数据,从而做到一个通用性很强的代码段只编写一次,而被以多种方式使用。大多数程序使用几种不同的子例程。其中最常用的是函数、过程、库程序、系统程序以及设备驱动程序。函数是一种短子例程,用来计算某个值,如角的计算,而该值计算机仅用一条基本指令无法计算。过程执行的是复杂一些的功能,如给一组名称排序。库程序是为许多不同的程序使用而编写的子例程。系统程序和
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二零二四年物联网平台建设合同标的及服务内容2篇
- 2024年度城市供水管网建设项目融资合同2篇
- 土地勘测定界测绘合同
- 二零二四年基础设施建设项目合同3篇
- 2024年度新能源车辆采购与技术合作协议2篇
- 二零二四年度物业管理与设施维护合同
- 2024年度二手箱包买卖合同3篇
- 2024年度版权许可使用合同授权范围与授权期限规定2篇
- 二零二四年度酒店客房软装装修合同2篇
- 2024年度版权许可使用合同许可期限与使用范围2篇
- 大数据与财务管理大学生职业规划
- 老年病科发展规划
- 毛概中国特色社会主义理论体系课件
- 团播主持人协议
- 人教版数学四年级上册全册各单元教材解读教材解析
- 上海率先实现全面智慧交通系统
- 食物的分类课件
- 急需学科专业引导发展清单
- 中国传统体育文化分析报告
- 2024年廉洁文化线上知识竞赛题库及答案
- 小学四年级奥数培训教材
评论
0/150
提交评论