购买
下载掌阅APP,畅读海量书库
立即打开
畅读海量书库
扫码下载掌阅APP

Unit 5
Computer Languages
计算机语言

A computer must be given instructions in a language that it understands, that is, a particular pattern of binary digital information. On the earliest computers, programming was a difficult, laborious task, because vacuum tube ON/OFF switches had to be set by hand. Teams of programmers often took days to program simple tasks, such as sorting a list of names. Since that time a number of computer languages have been devised, some with particular kinds of functioning in mind and others aimed more at ease of use—the user-friendly approach.

Machine Language

Unfortunately, the computer's own binary based language, or machine language, is difficult for humans to use. The programmer must input every command and all data in binary form, and a basic operation such as comparing the contents of a register to the data in a memory chip location might look like this:11001010 00010111 11110101 00101011.Machine language programming is such a tedious, time-consuming task that the time saved in running the program rarely justifies the days or weeks needed to write the program.

Assembly Language

One method programmers devised to shorten and simplify the process is called assembly language programming. By assigning a short(usually three letter)mnemonic code to each machine language command, assembly language programs could be written and-debugged-cleaned of logic and date errors-in a fraction of the time needed by machine language programmers. In assembly language, each mnemonic command and its symbolic operands equals one machine instruction. An assembler program translates the mnemonic opcodes(operation codes)and symbolic operands into binary language and executes the program. Assembly language is a type of low level computer programming language in which each statement corresponds directly to a single machine instruction. Assembly languages are, thus, specific to a given processor. After writing an assembly language program, the programmer must use the assembler language into machine code. Assembly language provides precise control of the computer, but assembly language programs written for one type of computer must be rewritten to operate on another type. Assembly language might be used instead of a high level language for any of three major reasons:speed, control, and preference. Programs written in assembly language usually run faster than those generated by a compiler;use of assembly language lets a programmer interact directly with the hardware(processor, memory, display, and input/output ports).Assembly language, however, can be used only with one type of CPU chip or microprocessor. Programmers who expended much time and effort to learn how to program one computer had to learn a new programming style each time they worked on another machine. What was needed was a shorthand method by which one symbolic statement could represent a sequence of many machine language instructions, and a way that would allow the same program to run on several types of machines. These needs led to the development of so-called high level languages.

High Level Languages

High level languages often use English-like words—for example, LIST, PRINT, OPEN, and so on—as commands that might stand for a sequence of tens or hundreds of machine language instructions. The commands are entered from the keyboard or from a program in memory or in a storage device, and they are interpreted by a program that translates them into machine language instructions.

Translator programs are of two kinds:interpreters and compilers. With an interpreter, programs that loop back to reexecute part of their instructions reinterpret the same instructions each time it appears, so interpreted programs run much more slowly than machine language programs. Compilers, by contrast, translate an entire program into machine language prior to execution, so such programs run as rapidly as though they were written directly in machine language.

American computer scientist Grace Hopper is credited with implementing the first commercially oriented computer language. After programming an experimental computer at Harvard University , she worked on the UNIVAC I and II computers and developed a commercially usable high level programming language called FLOW MATIC to facilitate computer use in scientific applications. IBM then developed a language that would simplify work involving complicated mathematical formulas. Begun in 1954 and completed in 1957, FORTRAN(FORmula TRANslator) was the first comprehensive high level programming language that was widely used. In 1957, the Association for Computing Machinery set out to develop a universal language that would correct some of FORTRAN's perceived faults. A year later, they released ALGOL (ALGOrithmic Language), another scientifically oriented language;widely used in Europe in the 1960s and 1970s, it has since been superseded by newer languages, while FORTRAN continues to be used because of the huge investment in existing programs. COBOL (COmmon Business Oriented Language), a commercial and business programming language, concentrates on data organization and file handling and is widely used today in business.

BASIC (Beginners All-purpose Symbolic Instruction Code)was developed at Dartmouth College in the early 1960s for use by nonprofessional computer users. The language came into almost universal use with the microcomputer explosion of the 1970s and 1980s. Condemned as slow, inefficient, and inelegant by its detractors, BASIC is nevertheless simple to learn and easy to use. Because many early microcomputers were sold with BASIC built into the hardware(in ROM memory)the language rapidly came into widespread use. As a very simple example of a BASIC program, consider the addition of the numbers 1 and 2, and the display of the result. This is written as follows(the numerals 10—40 are line numbers):

10 A=1

20 B=2

30 C=A+B

40 PRINT C

Although hundreds of different computer languages and variants exist, several others deserve mention. PASCAL , originally designed as a teaching tool, is now one of the most popular microcomputer languages. LOGO was developed to introduce children to computers. C, a language Bell Laboratories designed in the 1970s, is widely used in developing systems programs, such as language translators. LISP and PROLOG are widely used in artificial intelligence.

COBOL

COBOL, in computer science, acronym for COmmon Business-oriented language, is a verbose, English-like programming language developed between 1959 and 1961.Its establishment as a required language by the U. S.Department of Defense, its emphasis on data structures, and its English-like syntax(compared to those of FORTRAN and ALGOL)led to its widespread acceptance and usage, especially in business applications. Programs written in COBOL, which is a compiled language, are split into four divisions:Identification, Environment, Data, and Procedure. The Identification division specifies the name of the program and contains any other documentation the programmer wants to add. The Environment division specifies the computer(s)being used and the files used in the program for input and output. The Data division describes the data used in the program. The Procedure division contains the procedures that dictate the actions of the program.

C&C++

A widely used programming language, C was developed by Dennis Ritchie at Bell Laboratories in 1972;it was so named because its immediate predecessor was the B programming language. Although C is considered by many to be more a machine independent assembly language than a high level language, its close association with the UNIX operating system, its enormous popularity, and its standardization by the American National Standards Institute(ANSI) have made it perhaps the closest thing to a standard programming language in the microcomputer/workstation marketplace. C is a compiled language that contains a small set of built in functions that are machine dependent. The rest of the C functions are machine independent and are contained in libraries that can be accessed from C programs. C programs are composed of one or more functions defined by the programmer;thus, C is a structured programming language. C++, in computer science, is an object oriented version of the C programming language, developed by Bjarne Stroustrup in the early 1980s at Bell Laboratories and adopted by a number of vendors, including Apple Computer, Sun Microsystems, Borland International, and Microsoft Corporation.

Exercises

I. Choose the best answer for each of the following :

1. The vacuum-tube ON/OFF switches of the earliest computers were set manually;as a result, _____.

A. a number of computer language came into wide use

B. a computer language had to be a binary pattern

C. programming was boring and not easy

D. the tasks performed by a computer were made simple

2. Which is true of the machine language?

A. The machine language is easy for machines to use.

B. Human beings can use the machine language easily.

C. All data and commands have to be in a binary form.

D. Running a program takes a longer time than writing the program.

3. People devised assembly language in order to_____.

A. simplify the process of programming

B. shorten the time to run a machine language

C. assign mnemonic code to each machine language command

D. translate the symbolic operands into mnemonic codes

4. In paragraph 4, the author tries to tell us that_____.

A. assembly language is a much higher level language than machine language

B. assembly language written for one kind of computer can’t be used by another

C. assembly language is a high level language

D. programs written by a compiler run faster than those created in assembly language

5. The development of so called high level language came into being as a result of_____.

A. a shorthand method by which one symbolic statement could represent a sequence of many machine language instructions

B. a way that would allow the same program to run on several types of machines

C. both A and B

D. none of the above

6. Which of the following are high-level languages?

A. COBOL, FORTRAN, ASSEMBLER, PASCAL.

B. MACHINE LANGUAGE, LIST, BASIC, PROLOG.

C. COMPILER, FLOW MATIC, ALGOL, LOGO.

D. None of the above.

7. Which of the following is not a characteristic of a high-level language?

A. It uses English-like words.

B. A command may stand for a sequence of many machine language instructions.

C. A keyboard can serve as an input device.

D. Machine language instructions are no longer required.

8. Which is not true of BASIC?

A. It was developed at Bell Laboratories in the early 1960s.

B. With the explosion of microcomputers, it found wide use in the 1970s.

C. It was thought of as a slow, inefficient programming language.

D. It was built into the hardware of many early microcomputers.

9. From paragraph 8, we can infer that_____.

A. FORTRAN was the first commercially oriented computer language

B. COBOL is a scientifically oriented language

C. because ALGOL was released later than FORTRAN, it has fewer faults

D. IBM was known for its commercially oriented computer language FLOW MATIC

10. Which of the following is true?

A. PASCAL was designed to introduce children to computers.

B. LOGO was originally created as a teaching tool.

C. PROLOG is widely used in developing system programs.

D. LISP plays a very important part in artificial intelligence.

II. Explain the following abbreviations :

1. FORTRAN:

2. COBOL:

3. ALGOL:

4. LISP:

5. BASIC:

6. PROLOG:

7. PASCAL: Ob55H5P2EsJqpqkcBLcNEczYBs/urJhKTBEegU+mNoq2nETBitmw50/AK3/SN3EQ

点击中间区域
呼出菜单
上一章
目录
下一章
×