1、UNIT7 Programming Language 7-1 Technical Part7-2 Reading Material 7-1 Technical Part 7-1-1 DefinitionA programming language is an artificial language designed to communicate instructions to a machine,particularly a computer.Programming languages can be used to create programs that control the behavi
2、our of a machine and/or to express algorithms precisely.It is also a set of grammatical rules for instructing a computer to perform specific tasks.For example:int main()printf(“Hello Worldn”);The above program is written in programming language.The program that is made from this code puts the words“
3、Hello World”onto the screen.7-1-2 IntroductionsProgramming Language TypesThe term programming language usually refers to high-level languages,such as BASIC,C,C+,COBOL,FORTRAN,Ada,and Pascal.Each language has a unique set of keywords(words that it understands)and a special syntax for organizing progr
4、am instructions.The programming languages can be categorized into high-level programming language,assembly language,machine language and 4GL(See Figure 7-1).Figure 7-1 Programming Language TypesHigh-Level programming languages,while simple compared to human languages,are more complex than the langua
5、ges the computer actually understands,called machine languages.Each different type of CPU has its own unique machine language.Lying between Machine Languages and High-Level Languages are languages called Assembly Languages.Assembly Languages are similar to Machine Languages,but they are much easier
6、to program in because they allow a programmer to substitute names for numbers.Machine Languages consist of numbers only.Lying above High-Level Languages are languages called fourth-generation languages(usually abbreviated 4GL).4GLs are far removed from Machine Languages and represent the class of co
7、mputer languages closest to human languages.Regardless of what language you use,you eventually need to convert your program into Machine Language so that the computer can understand it.There are two ways to do this:compile the program interpret the programThe Choice of Programming LanguageThe questi
8、on of which language is best is one that consumes a lot of time and energy among computer professionals.Every language has its strengths and weaknesses.For example,FORTRAN is a particularly good language for processing numerical data,but it does not lend itself very well to organizing large programs
9、.Pascal is very good for writing well-structured and readable programs,but it is not as flexible as the C programming language.C+embodies powerful object-oriented features,but it is complex and difficult to learn.The choice of which language to use depends on the type of computer the program is to r
10、un on,what sort of program it is,and the expertise of the programmer.Several Commonly Used Web Design Language1.HTMLHyperText Markup Language(HTML)is the main markup language for displaying web pages and other information that can be displayed in a web browser.HTML is written in the form of HTML ele
11、ments consisting of tags enclosed in angle brackets(like),within the web page content.HTML tags most commonly come in pairs like and,although some tags,known as empty elements,are unpaired,for example.The first tag in a pair is the start tag,the second tag is the end tag(they are also called opening
12、 tags and closing tags).In between these tags web designers can add text,tags,comments and other types of text-based content.The purpose of a web browser is to read HTML documents and compose them into visible or audible web pages.The browser does not display the HTML tags,but uses the tags to inter
13、pret the content of the page.HTML elements form the building blocks of all websites.HTML allows images and objects to be embedded and can be used to create interactive forms.It provides a means to create structured documents by denoting structural semantics for text such as headings,paragraphs,lists
14、,links,quotes and other items.It can embed scripts in languages such as JavaScript which affect the behavior of HTML web pages.Web browsers can also refer to Cascading Style Sheets(CSS)to define the appearance and layout of text and other material.The W3C,maintainer of both the HTML and the CSS stan
15、dards,encourages the use of CSS over explicitly presentational HTML markup.2.XMLExtensible Markup Language(XML)is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.It is defined in the XML 1.0 Specification produced by t
16、he W3C,and several other related specifications,all gratis open standards.The design goals of XML emphasize simplicity,generality,and usability over the Internet.It is a textual data format with strong support via Unicode for the languages of the world.Although the design of XML focuses on documents
17、,it is widely used for the representation of arbitrary data structures,for example in web services.Many Application Programming Interfaces(APIs)have been developed for software developers to use to process XML data,and several schema systems exist to aid in the definition of XML-based languages.As o
18、f 2009,hundreds of XML-based languages have been developed,including RSS,Atom,SOAP,and XHTML.XML-based formats have become the default for many office-productivity tools,including Microsoft Office(Office Open XML),OpenOffice.org and LibreOffice(OpenDocument),and Apples iWork.XML has also been employ
19、ed as the base language for communication protocols,such as XMPP.3.JavaScriptJavaScript(sometimes abbreviated JS)is a prototype-based scripting language that is dynamic,weakly typed and has first-class functions.It is a multi-paradigm language,supporting object-oriented,imperative,and functional pro
20、gramming styles.JavaScript was formalized in the ECMAScript language standard and is primarily used in the form of client-side JavaScript,implemented as part of a Web browser in order to give enhanced user interfaces and dynamic websites.This enables programmatic access to computational objects with
21、in a host environment.JavaScripts use in applications outside Web pages for example in PDF documents,site-specific browsers,and desktop widgets is also significant.Newer and faster JavaScript VMs and frameworks built upon them(notably Node.js)have also increased the popularity of JavaScript for serv
22、er-side web applications.JavaScript uses syntax influenced by that of C.JavaScript copies many names and naming conventions from Java,but the two languages are otherwise unrelated and have very different semantics.The key design principles within JavaScript are taken from the Self and Scheme program
23、ming languages.4.VBScriptVBScript(Visual Basic Scripting Edition)is an Active Scripting language developed by Microsoft that is modeled on Visual Basic.It is designed as a“lightweight”language with a fast interpreter for use in a wide variety of Microsoft environments.VBScript uses the Component Obj
24、ect Model to access elements of the environment within which it is running;for example,the File System Object(FSO)is used to create,read,update and delete files.VBScript has been installed by default in every desktop release of Microsoft Windows since Windows 98;in Windows Server since Windows NT 4.
25、0 Option Pack;and optionally with Windows CE(depending on the device it is installed on).A VBScript script must be executed within a host environment,of which there are several provided with Microsoft Windows,including:Windows Script Host(WSH),Internet Explorer(IE),and Internet Information Services(
26、IIS).Additionally,the VBScript hosting environment is embeddable in other programs,through technologies such as the Microsoft Script Control(msscript.ocx).7-1-3 Application Case or ExampleExample of C Programming LanguageOut of the many programming languages available C programming language is a mul
27、tipurpose general computer programming language which was formed at the Bell Telephone Laboratories by Dennis Ritchie in 1972.The primary purpose it was meant to serve was to be used as system software in Unix operating systems.However it is now used more widely to create portable application softwa
28、re.As one of the most well accepted programming languages in the history of computers there are very few computer designs which are not compatible with C programming language.Other prevalent versions of programming languages like say C+have been incredibly influenced by C and began merely as an addi
29、tion to C.Designed to be assembled using a simple compiler and to offer low-level entry to memory,C Programming Language provides machine instruction mapping language constructs which require negligible support during run-time.This makes C useful in various other applications which have been traditi
30、onally designed using assembly language.The only way to learn a new programming language is by writing programs in it.The first program to write is the same for all languages.Print the words hello,world.This is a big hurdle;to leap over it you have to be able to create the program text somewhere,com
31、pile it successfully,load it,run it,and find out where your output went.With these mechanical details mastered,everything else is comparatively easy.In C,the program to print“hello,world”is#include main()printf(“hello,worldn”);Just how to run this program depends on the system you are using.As a spe
32、cific example,on the UNIX operating system you must create the program in a file whose name ends in“.c”,such as hello.c,then compile it with the command.cc hello.cIf you havent botched anything,such as omitting a character or misspelling something,the compilation will proceed silently,and make an ex
33、ecutable file called a.out.If you run a.out by typing the command a.out it will print hello,world On other systems,the rules will be different;check with a local expert.7-2 Reading Material 7-2-1 Reading ComprehensionHistory of Programming LanguagesThe first programming languages predate the modern
34、computer.At first,the languages were codes.The Jacquard loom,invented in 1801,used holes in punched cards to represent sewing loom arm movements in order to generate decorative patterns automatically.During a nine-month period in 1842-1843,Ada Lovelace translated the memoir of Italian mathematician
35、Luigi Menabrea about Charles Babbages newest proposed machine,the Analytical Engine.With the article,she appended a set of notes which specified in complete detail a method for calculating Bernoulli numbers with the Engine,recognized by some historians as the worlds first computer program.Herman Hol
36、lerith realized that he could encode information on punch cards when he observed that train conductors encode the appearance of the ticket holders on the train tickets using the position of punched holes on the tickets.Hollerith then encoded the 1890 census data on punch cards.The first computer cod
37、es were specialized for their applications.In the first decades of the 20th century,numerical calculations were based on decimal numbers.Eventually it was realized that logic could be represented with numbers,not only with words.For example,Alonzo Church was able to express the lambda calculus in a
38、formulaic way.The Turing machine was an abstraction of the operation of a tape-marking machine,for example,in use at the telephone companies.Turing machines set the basis for storage of programs as data in the von Neumann architecture of computers by representing a machine through a finite number.Ho
39、wever,unlike the lambda calculus,Turings code does not serve well as a basis for higher-level languagesits principal use is in rigorous analyses of algorithmic complexity.Like many“firsts”in history,the first modern programming language is hard to identify.From the start,the restrictions of the hard
40、ware defined the language.Punch cards allowed 80 columns,but some of the columns had to be used for a sorting number on each card.FORTRAN included some keywords which were the same as English words,such as“IF”,“GOTO”(go to)and“CONTINUE”.The use of a magnetic drum for memory meant that computer progr
41、ams also had to be interleaved with the rotations of the drum.Thus the programs were more hardware-dependent.To some people,what was the first modern programming language depends on how much power and human-readability is required before the status of“programming language”is granted.Jacquard looms a
42、nd Charles Babbages Difference Engine both had simple,extremely limited languages for describing the actions that these machines should perform.One can even regard the punch holes on a player piano scroll as a limited domain-specific language,albeit not designed for human consumption.Words&Expressio
43、nspunched card=punch card n.穿孔卡;打孔卡片 encode vt.编码,译码numerical adj.数值的;数字的;用数字表示的(等于numeric)decimal number n.十进制数;小数 calculation n.计算;估计;计算的结果;深思熟虑lambda calculus n.演算 Turing machine n.图灵机Von Neumann architecture n.冯诺依曼体系结构principal adj.首要的;最重要的rigorous adj.严格的,严厉的;严密的;严酷的algorithmic adj.算法的;规则系统的com
44、plexity n.复杂,复杂性;错综复杂的事物identify vi.确定;认同;一致;vt.确定;识别;使参与;把看成一样magnetic drum n.磁鼓rotation n.旋转;循环,轮流interleave vt.交错;插空白页于;插叙consumption n.消费;消耗7-2-2 ExercisesI.The Single Item Choice.1.What is the first programming language?_A.Using holes in punched card.B.Using Turing machine.C.FORTRAN language.D.
45、Using a magnetic drum.2.Who proposed the Analytical Engine?_A.Ada Lovelace.B.Luigi Menabrea.C.Charles Babbage.D.Herman Hollerith.3.Which statement is correct below?_A.Logic could only be represented with numbers.B.Logic could not be represented with numbers.C.Logic could only be represented with wor
46、ds.D.Logic not only could be represented with numbers but also with words.4.Why is the first modern programming language hard to identify?_A.Because no one knows which programming language is good for use.B.Because the programs were more hardware-dependent.C.Because there exist many programming lang
47、uages.D.Because the programming language has nothing to do with hardware.5.To some people,what can confirm the first modern programming language?_A.How much power and human-readability is required.B.Punch holes on a player piano scroll.C.Hardware.D.Domain-specific language.II.Fill in each of the bla
48、nks with one of the words given in the following list,making changes if necessary.scripting language,client-side,first-class functions,site-specific,Web pages,multi-paradigm,implement,server-side,desktop widgets,naming conventionsJavaScript(sometimes abbreviated JS)is a prototype-based that is dynam
49、ic,weakly typed and has .It is a language,supporting object-oriented,imperative,and functional programming styles.JavaScript was formalized in the ECMAScript language standard and is primarily used in the form of JavaScript,as part of a Web browser in order to give enhanced user interfaces and dynam
50、ic websites.This enables programmatic access to computational objects within a host environment.JavaScripts use in applications outside for example in PDF documents,browsers,and is also significant.Newer and faster JavaScript VMs and frameworks built upon them(notably Node.js)have also increased the