Скачиваний:
11
Добавлен:
25.05.2014
Размер:
578.56 Кб
Скачать

Application of Programming Languages

Programming languages allow people to communicate with computers. Once a job has been identified, the programmer must translate, or code, it into a list of instructions that the computer will understand. A computer program for a given task may be written in several different languages. Depending on the task, a programmer will generally pick the language that will involve the least complicated program. It may also be important to the programmer to pick a language that is flexible and widely compatible if the program will have a range of applications. The examples shown here are programs written to average a list of numbers. Both C and BASIC are commonly used programming languages. The machine interpretation shows how a computer would process and execute the commands from the programs.

Programming languages vary greatly in their sophistication and in their degree of versatility. Some programming languages are written to address a particular kind of computing problem or for use on a particular model of computer system. For instance, programming languages such as Fortran and COBOL were written to solve certain general types of programming problems—Fortran for scientific applications, and COBOL for business applications. Although these languages were designed to address specific categories of computer problems, they are highly portable, meaning that they may be used 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 computer in certain research applications. The most commonly used programming languages are highly portable and can be used to effectively solve diverse types of computing problems. Languages like C, PASCAL, and BASIC fall into this category.

II

LANGUAGE TYPES

Programming languages can be classified as either low-level languages or high-level languages. Low-level programming languages, or machine languages, are the most basic type of programming languages and can be understood directly by a computer. Machine languages differ depending on the manufacturer and model of computer. High-level languages are programming languages that must first be translated into a machine language before they can be understood and processed by a computer. Examples of high-level languages are C, C++, PASCAL, and Fortran. Assembly languages are intermediate languages that are very close to machine language and do not have the level of linguistic sophistication exhibited by other high-level languages, but must still be translated into machine language.

A

Machine Languages

In machine languages, instructions are written as sequences of 1s and 0s, called bits, that a computer can 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 memory (Random Access Memory, or RAM), (2) a simple operation to perform, such as adding the two numbers together, (3) where in the main memory 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 by the computer in machine language, they are not all programmed in machine language. It is extremely difficult 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 contents of storage register A to the contents of storage register B.

B

High-Level Languages

 High-level languages are relatively sophisticated sets of statements utilizing words and syntax from human language. They are more similar to normal human languages than assembly or machine languages and are therefore easier to use for writing complicated programs. These programming languages allow larger and more complicated programs to be developed faster. However, high-level languages must be translated into machine language by another program called a compiler before a computer can understand them. For this reason, programs written in a high-level language may take longer to execute and use up more memory than programs written in an assembly language.

C

Assembly Language

Computer programmers use assembly languages to make machine-language programs easier to write. In an assembly language, each statement corresponds roughly to one machine language instruction. An assembly language statement is composed with the aid of easy to remember commands. The command to add the contents of the storage register A to the contents of storage register B might be written ADD B,A in a typical assembly language statement. Assembly languages share certain features with machine languages. For instance, it is possible to manipulate specific bits in both assembly and machine languages. Programmers use assembly languages 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 used when some part of the computer has to be controlled directly, such as individual dots on a monitor or the flow of individual characters to a printer.

III

CLASSIFICATION OF HIGH-LEVEL LANGUAGES

High-level languages are commonly classified as procedure-oriented, functional, object-oriented, or logic languages. The most common high-level languages today are procedure-oriented languages. In these languages, one or more related blocks of statements that perform some complete function are grouped together into a program module, or procedure, and given a name such as “procedure A.” If the same sequence of operations is needed elsewhere in the program, a simple statement can be used to refer back to the procedure. In essence, a procedure is just a mini-program. A large program can be constructed by grouping together procedures that perform different tasks. Procedural languages allow programs to be shorter and easier for the computer to read, but they require the programmer to design each procedure to be general enough to be used in different situations.

Functional languages treat procedures like mathematical functions and allow them to be processed like any other data in a program. This allows a much higher and more rigorous level of program construction. Functional languages also allow variables—symbols for data that can be specified and changed by the user as the program is running—to be given values only once. This simplifies programming by reducing the need to be concerned with the exact order of statement execution, since a variable does not have to be redeclared, or restated, each time it is used in a program statement. Many of the ideas from functional languages have become key parts of many modern procedural languages.

Object-oriented languages are outgrowths of functional languages. In object-oriented languages, the code used to write the program and the data processed by the program are grouped together into units called objects. Objects are further grouped into classes, which define the attributes objects must have. A simple example of a class is the class Book. Objects within this class might be Novel and Short Story. Objects also have certain functions associated with them, called methods. The computer accesses an object through the use of one of the object’s methods. The method performs some action to the data in the object and returns this value to the computer. Classes of objects can also be further grouped into hierarchies, in which objects of one class can inherit methods from another class. The structure provided in object-oriented languages makes them very useful for complicated programming tasks.

Logic languages use logic as their mathematical base. A logic program consists of sets of facts and if-then rules, which specify how one set of facts may be deduced from others, 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 statements in the program. Many artificial intelligence programs are written in such languages.

IV

LANGUAGE STRUCTURE AND COMPONENTS

Programming languages use specific types of statements, or instructions, to provide functional structure to the program. A statement in a program is a basic sentence that expresses a simple idea—its purpose is to give the computer a basic instruction. Statements define the types of data allowed, how data are to be manipulated, and the ways that procedures and functions work. Programmers use statements to manipulate common components of programming languages, such as variables and macros (mini-programs within a program).

Statements known as data declarations give names and properties to elements of a program called variables. Variables can be assigned different values within the program. The properties variables can have are called types, and they include such things as what possible values might be saved in the variables, how much numerical accuracy is to be used in the values, and how one variable may represent a collection of simpler values in an organized fashion, such as a table or array. In many programming languages, a key data type is a pointer. Variables that are pointers do not themselves have values; instead, they have information that the computer can use to locate some other variable—that is, they point to another variable.

An expression is a piece of a statement that describes a series of computations to be performed on some of the program’s variables, such as X + Y/Z, in which the variables are X, Y, and Z and the computations are addition and division. An assignment statement assigns a variable a value derived from some expression, while conditional statements specify expressions to be tested and then used to select which other statements should be executed next.

Procedure and function statements define certain blocks of code as procedures or functions that can then be returned to later in the program. These statements also define the kinds of variables and parameters the programmer can choose and the type of value that the code will return when an expression accesses the procedure or function. Many programming languages also permit minitranslation programs called macros. Macros translate segments of code that have been written in a language structure defined by the programmer into statements that the programming language understands.

V

HISTORY

Programming languages date back almost to the invention of the digital computer in the 1940s. The first 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 (FORmula TRANslation), created by John Backus, and then COBOL (COmmon Business Oriented Language), created by Grace Hopper. The first functional language was LISP (LISt Processing), written by John McCarthy in the late 1950s. Although heavily updated, all three languages are still widely used today.

In the late 1960s, the first object-oriented languages, such as SIMULA, emerged. Logic languages became well known in the mid 1970s with the introduction of PROLOG, a language used to program artificial intelligence software. During the 1970s, procedural languages continued to develop with ALGOL, BASIC, PASCAL, C, and Ada. SMALLTALK was a highly influential object-oriented language that led to the merging of object-oriented and procedural languages in C++ and more recently in JAVA. Although pure logic languages have declined in popularity, variations have become vitally important in the form of relational languages for modern databases, such as SQL (Structured Query Language).

Fortran

Fortran, in computer science, acronym for FORmula TRANslation. The first high-level computer language (developed 1954-1958 by John Backus) and the progenitor of many key high-level concepts, such as variables, expressions, statements, iterative and conditional statements, separately compiled subroutines, and formatted input/output. Fortran is a compiled, structured language. The name indicates its scientific and engineering roots; Fortran is still used heavily in those fields, although the language itself has been expanded and improved vastly over the last 35 years to become a language that is useful in any field.

COBOL

COBOL, in computer science, acronym for COmmon Business-Oriented Language, 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. See also Computer.

C (computer)

C (computer), in computer science, a programming language developed by Dennis Ritchie at Bell Laboratories in 1972; 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.

Pascal (computer)

Pascal (computer), a concise procedural computer programming language, designed 1967-71 by Niklaus Wirth. Pascal, a compiled, structured language, built upon ALGOL, simplifies syntax while adding data types and structures such as subranges, enumerated data types, files, records, and sets. Acceptance and use of Pascal exploded with Borland International's introduction in 1984 of Turbo Pascal, a high-speed, low-cost Pascal compiler for MS-DOS systems that has sold over a million copies in its various versions. Even so, Pascal appears to be losing ground to C as a standard development language on microcomputers.

BASIC

BASIC, in computer science, acronym for Beginner's All-purpose Symbolic Instruction Code. A high-level programming language developed by John Kemeny and Thomas Kurtz at Dartmouth College in the mid-1960s. BASIC gained its enormous popularity mostly because of two implementations, Tiny BASIC and Microsoft BASIC, which made BASIC the first lingua franca of microcomputers. Other important implementations have been CBASIC (Compiled BASIC), Integer and Applesoft BASIC (for the Apple II), GW-BASIC (for the IBM PC), Turbo BASIC (from Borland), and Microsoft QuickBASIC. The language has changed over the years. Early versions are unstructured and interpreted. Later versions are structured and often compiled. BASIC is often taught to beginning programmers because it is easy to use and understand and because it contains the same major concepts as many other languages thought to be more difficult, such as Pascal and C.

C++

C++, in computer science, 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.

Assembly Language

Assembly Language, in computer science, 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 specific to the microprocessor to translate the assembly 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).

LISP

LISP, in computer science, acronym for List Processing. A list-oriented computerprogramming language developed in 1959-1960 by John McCarthy and used primarily to manipulate lists of data. LISP was a radical departure from the procedural languages (Fortran, ALGOL) then being developed; it is an interpreted language in which every expression is a list of calls to functions. LISP continues to be heavily used in research and academic circles and has long been considered the “standard” language for artificial-intelligence (AI) research, although Prolog has made inroads into that claim in recent years.

PROLOG

PROLOG, in computer science, an acronym for programming in logic, a computer programming language important in the development of artificial intelligence software during the 1970s and 1980s. Unlike traditional programming languages, which process only numerical data and instructions, PROLOG processes symbols and relationships. It is designed to perform search functions that establish relationships within a program. This combination of symbolic processing and logic searching made PROLOG the preferred language during the mid-1980s for creating programs that mimic human behavior.

PROLOG was developed in 1970 at the University of Marseille in France by Alain Colmerauer. Colmerauer believed that traditional computer-programming languages, such as Fortran and COBOL, were inappropriate for representing human logic in a machine. Colmerauer's primary goal was to communicate with computers using conversational language instead of programmer's jargon. He concluded that strict symbolic logic was the appropriate bridge between human and machine.

A PROLOG program is made up of facts and rules that are usually limited to a single domain, such as marine life, accounting, or aircraft maintenance. Once a database is built for that domain, PROLOG searches the database and forms relationships between facts. PROLOG's functions are designed to prove that a proposition is either valid or invalid. This is done by applying logic to the available facts, such as “A hammerhead is a shark” and “Madeline likes all sharks.” Rules are built by combining facts: “Madeline likes X, and X is a shark.” If the program's database identifies certain symbolic entities—such as hammerheads, makos, and great whites—as sharks, then PROLOG can use the rule to determine that Madeline likes hammerheads, makos, and great whites, even though that information was not specifically programmed into the database.

This form of artificial intelligence is valuable in situations in which a fault or malfunction can be specifically identified—as in equipment maintenance and repair—and in cases in which the answers are of the YES/NO or TRUE/FALSE variety. Due to the rigidity of the applied logic, however, PROLOG has difficulty with imprecise data or fuzzy sets.

In the United States the artificial-intelligence community of the late 1970s ignored PROLOG in favor of a competing artificial-intelligence language, LISP, which was developed by John McCarthy at the Massachusetts Institute of Technology in Cambridge, Massachusetts. In Europe, however, PROLOG captured the interest of researchers and by the mid-1980s it became the preferred language for building expert systems. In 1981, when the Japanese government initiated a national project to develop commercial artificial intelligence, it adopted PROLOG as its standard programming language.

Many of the features that were once unique to PROLOG are now used in modern object-oriented programming, a programming technique that is becoming the standard for software development.

Object-Oriented Programming

Object-Oriented Programming (OOP), in computer science, type of high-level computer language that uses self-contained, modular instruction sets for defining and manipulating aspects of a computer program. These discrete, pre-defined instruction sets are called objects and may be used to define variables, data structures, and procedures for executing data operations. In OOP, objects have built-in rules for communicating with one another. They can also be manipulated or combined in various ways to modify existing programs and to create entirely new ones from pieces of other programs. See also Computer Program, Programming Language.

One especially powerful feature of OOP languages is a property known as inheritance. Inheritance allows an object to take on the characteristics and functions of other objects to which it is functionally connected. Programmers connect objects by grouping them together in different classes and by grouping the classes into hierarchies. These classes and hierarchies allow programmers to define the characteristics and functions of objects without needing to repeat source code, the coded instructions in a program. Thus, using OOP languages can greatly reduce the time it takes for a programmer to write an application, and also reduce the size of the program. OOP languages are flexible and adaptable, so programs or parts of programs can be used for more than one task. Programs written with OOP languages are generally shorter in length and contain fewer bugs, or mistakes, than those written with non-OOP languages.

The first OOP language was Smalltalk, developed by Alan Kay at the Palo Alto Research Center of the Xerox Corporation in the early 1970s. By using objects, Smalltalk allowed programmers to focus on and specify the task to be performed from the top down, rather than laboring on detailed, ground-up procedures, which were embedded in the language structure. Smalltalk, however, has not found widespread use.

The most popular OOP language is C++, developed by Bjarne Stroustrup at Bell Laboratories in the early 1980s. In May 1995 Sun Microsystems, Inc. released Java, a new OOP language, which has drawn worldwide interest. In some ways Java represents a simplified version of C++, but it adds other features and capabilities as well, and is particularly well suited for writing interactive applications to be used on the World Wide Web.

Ada

Ada, in computer science, a procedural programming language designed under the direction of the U.S. Department of Defense (DOD) in the late 1970s and intended to be the primary language for DOD software development. Ada, named after (Augusta) Ada Byron, Countess of Lovelace, who was a pioneer in the field of computers, was derived from Pascal but has major semantic and syntactical extensions, including concurrent execution of tasks, overloading of operators, and modules.

Java (computer)

Java (computer), in computer science, object-oriented programming language introduced in 1995 by Sun Microsystems, Inc. Java facilitates the distribution of both data and small applications programs, called applets, over the Internet. Java applications do not interact directly with a computer’s central processing unit (CPU) or operating system and are therefore platform independent, meaning that they can run on any type of personal computer, workstation, or mainframe computer. This cross-platform capability, referred to as “write once, run everywhere,” has caught the attention of many software developers and users. With Java, software developers can write applications that will run on otherwise incompatible operating systems such as Windows, the Macintosh operating system, OS/2, or UNIX.

To use a Java applet on the World Wide Web (WWW)—the system of software and protocols that allows multimedia documents to be viewed on the Internet—a user must have a Java-compatible browser, such as Navigator from Netscape Communications Corporation, Internet Explorer from Microsoft Corporation, or HotJava from Sun Microsystems. A browser is a software program that allows the user to view text, photographs, graphics, illustrations, and animations on the WWW. Java applets achieve platform independence through the use of a virtual machine, a special program within the browser software that interprets the bytecode—the code that the applet is written in—for the computer’s CPU. The virtual machine is able to translate the platform-independent bytecode into the platform-dependent machine code that a specific computer’s CPU understands.

Applications written in Java are usually embedded in Web pages, or documents, and can be run by clicking on them with a mouse. When an applet is run from a Web page, a copy of the application program is sent to the user’s computer over the Internet and stored in the computer’s main memory. The advantage of this method is that once an applet has been downloaded, it can be interacted with in real time by the user. This is in contrast to other programming languages used to write Web documents and interactive programs, in which the document or program is run from the server computer. The problem with running software from a server is that it generally cannot be run in real time due to limitations in network or modembandwidth—the amount of data that can be transmitted in a certain amount of time.

Java grew out of a research project at Sun Microsystems in the early 1990s that focused on controlling different consumer electronics devices using the same software. The original version of Java, called Oak, needed to be simple enough to function with the modest microprocessors found in such consumer devices. Following the introduction of the National Center for Supercomputing Applications’ (NCSA) Mosaic browser in 1993, Oak was recast by Sun Microsystems developers. In 1994 Sun Microsystems released a Java-compatible Internet browser, called HotJava, that was designed to read and execute Java applets on the WWW. Netscape Communications licensed Java from Sun Microsystems in November 1995, and its Navigator 3.0 browser supports Java applications. Microsoft also licensed Java, in 1996, for its Internet Explorer 3.0 browser. Microsoft developed a programming language, called Visual J++, to integrate Java, through its ActiveX technology, with its browser. Visual J++ is optimized for the Windows operating system. Various other WWW browsers are also capable of supporting Java applications and applets.

JavaSoft, a division of Sun Microsystems with responsibility for Java and its business development, has created JavaOS, a compact operating system for use on its own JavaStation network computers, now in development, as well as, possibly, in cellular telephones and pagers.

Structured Query Language

Structured Query Language (SQL), in computer science, a database sublanguage used in querying, updating, and managing relational databases. Derived from an IBM research project that created Structured English Query Language (SEQUEL) in the 1970s, SQL is an accepted standard in database products. Although it is not a programming language in the same sense as C or Pascal, SQL can either be used in formulating interactive queries or be embedded in an application as instructions for handling data. The SQL standard also contains components for defining, altering, controlling, and securing data. SQL is designed for both technical and nontechnical users.

Hypertext Markup Language (HTML)

Hypertext Markup Language (HTML) in computer science, the standard text-formatting language since 1989 for documents on the interconnected computing network known as the World Wide Web. HTML documents are text files that contain two parts: content that is meant to be rendered on a computer screen; and markup or tags, encoded information that directs the text format on the screen and is generally hidden from the user. HTML is a subset of a broader language called Standard Generalized Markup Language (SGML), which is a system for encoding and formatting documents, whether for output to a computer screen or to paper.

Some tags in an HTML document determine the way certain text, such as titles, will be formatted. Other tags cue the computer to respond to the user's actions on the keyboard or mouse. For instance, the user might click on an icon (a picture that represents a specific command), and that action might call another piece of software to display a graphic, play a recording, or run a short movie. Another important tag is a link, which may contain the Uniform Resource Locator (URL) of another document. The URL can be compared to an address where a particular document resides. The document may be stored on the same computer as the parent document or on any computer connected to the World Wide Web. The user can navigate from document to document simply by clicking on these links. HTML also includes markups for forms, that let the user fill out information and electronically send, or e-mail, the data to the document author, initiate sophisticated searches of information on the Internet, or order goods and services.

The software that permits the user to navigate the World Wide Web and view HTML-encoded documents is called a browser. It interprets the HTML tags in a document and formats the content for screen display. Since HTML is an accepted standard, anyone can build a browser without concerning themselves with what form various documents will assume, unlike documents produced by typical word processors, which must be translated into a different format if another word processing application is used. Most sites on the World Wide Web adhere to HTML standards and, because HTML is easy to use, the World Wide Web has grown rapidly. HTML continues to evolve, however, so browsers must be upgraded regularly to meet the revised standards.

Computer Graphics

I

INTRODUCTION

Computer Graphics, two- and three-dimensional images created by computers that are used for scientific research, artistic pursuits, and in industries to design, test, and market products. Computer graphics have made computers easier to use. Graphical user interfaces (GUIs) and multimedia systems such as the World Wide Web, the system of interconnected worldwide computer resources, enable computer users to select pictures to execute orders, eliminating the need to memorize complex commands.

II

HOW COMPUTER GRAPHICS WORK

Before an image can be displayed on the screen it must be created by a computer program in a special part of the computer's memory, called a frame buffer. One method of producing an image in the frame buffer is to use a block of memory called a bitmap to store small, detailed figures such as a text character or an icon. A graphical image is created by dividing the computer's display screen into a grid of tiny dots called pixels. Frame buffer memory can also store other information, such as the color of each pixel.

A

Color Representation

Computers store and manipulate colors by representing them as a combination of three numbers. For example, in the Red-Green-Blue (RGB) color system, the computer uses one number each to represent the red, green, and blue primary components of the color. Alternate schemes may represent other color properties such as the hue (frequency of light), saturation (amount), and value (brightness).

If one byte of memory is used to store each color component in a three-color system, then over 16 million color combinations can be represented. But in the creation of a large image, allowing so many combinations can be very costly in terms of memory and processing time. An alternate method, color mapping, uses only one number per color combination, storing each number in a table of available colors like a painter's palette. The problem with color mapping is that the number of colors in the palette is usually too small to create realistically colored images. Choosing the colors that make the best image for the palette, called color quantization, becomes a very important part of the image-making process. Another method, called dithering, alternates the limited palette colors throughout the image—much like the patterns of dots in a newspaper comic strip—to give the appearance of more colors than are actually in the image.

B

Aliasing and Anti-Aliasing

Соседние файлы в папке Тексты по английскому. Физическая и компьюткрная направленность. МО-215а