Previous | Next | Table of Contents | Index | Program List | Copyright

1.5 Programming Languages

Writing a computer program requires knowing a system of instructions for the computer. There are many such systems; these have come to be called programming languages. Like human languages (often called natural languages by computer people), programming languages have vocabularies--or sets of acceptable words and grammars--or rules for combining words into larger units analogous to sentences and paragraphs.

There is an important distinction between programming languages and natural languages. Because a person can think, he or she can understand or "make sense" of another person's communication, even if the second person's grammar or usage is poor. Because a computer cannot think, it is far less tolerant of a programmer's poor grammar or usage and will usually stop and refuse to proceed until the errors are corrected. This is not as difficult as it may seem: Although natural languages grew over many centuries and are filled with irregularities and strange constructions, programming languages were designed by humans expressly to be consistent and regular and are therefore easier to learn and use than natural languages.

There are many different programming languages, which fall into three broad categories: machine, assembly, and high-level languages.

Machine Languages

Machine language is the native tongue of a computer. Each machine-language instruction is a binary sequence (string of 0s and 1s) that specifies an operation and the memory cells involved in the operation. Three instructions in a machine language might be:

    0010 0000 0000 0100
    0100 0000 0000 0101
    0011 0000 0000 0110
Obviously, what is easiest for a computer to understand is most difficult for a person to understand and vice versa. Each type of central processor has its own system of machine instructions. The Motorola 68040, the Intel Pentium, and the Sun SPARC are examples of different CPU types whose machine-language programs are not interchangeable.

Assembly Languages

Assembly language allows us to use descriptive names to reference data and instruction; however, each operation is typically a very small and specific one. The machine language above might have been written as
    LOAD Cost
    ADD Profit
    STORE Price 
in an assembly language. Generally, each assembly-language instruction represents one machine-language instruction for a specific type of computer. A program called an assembler is used to translate assembly language to machine language.

High-Level Languages

High-level languages (also called high-order languages, mostly by the U.S. government) are most often used by programmers (program writers). High-level languages are much easier to use than machine and assembly languages. A high-level language program is more portable. This means that it can be made to execute with little or no modification on many different types of computers.

Some common high-level languages are BASIC, FORTRAN, COBOL, Pascal, C, C++, and Ada. Each of these languages was designed with a specific purpose in mind. FORTRAN is an acronym for FORmula TRANslation, and its principal users have been engineers and scientists. BASIC (Beginners All-purpose Symbolic Instructional Code) was designed in the 1960s to be learned and used easily by students. COBOL (COmmon Business Oriented Language) is used primarily for business data-processing operations. Pascal (named for Blaise Pascal) was designed in the early 1970s as a language for teaching programming. C (whose developers designed B first) combines the power of an assembly language with the ease of use and portability of a high-level language. C++ is an extension of C that supports object-oriented programming.

Ada, the language of this book, was named for Ada, Countess of Lovelace, the nineteenth-century Englishwoman often credited with being the first programmer. In Chapter 2 we discuss the origins and history of both Ada the person and Ada the language.

One of the most important features of high-level languages is that they allow us to write program statements that resemble human language or everyday mathematics. We can reference data that are stored in memory using descriptive names (e.g., Name, Rate) rather than numeric memory cell addresses. We can also describe operations that we would like performed using familiar symbols. For example, in several high-level languages the statement

    Price = Cost + Profit 
means add Cost to Profit and store the result in Price.

Because a computer can execute only programs that are in its machine language, a high-level language program must be converted or translated into machine language before it can be executed. A program called a compiler carries out the translation; sometimes the compiler produces assembly language, which is then further translated by the assembler.The original high-level language program is called the source program; the resulting machine-language program is called the object program. Section 1.6 describes the steps required to process a high-level language program.

Portability and Compiler Standards

Each high-level language has a language standard, which is a document, agreed to by the community of language users and compiler developers, that describes the form and meaning of all its statements. Some languages (Pascal especially) have "dialects," or compiler versions, that make additional features available that are not part of the standard. To make a program portable, a programmer must be careful to use only those features that are part of the standard.

Happily, this is easier with Ada than with many other languages because the standard for Ada is a particularly strong one: Dialects are not allowed, and an Ada compiler is subjected to a strenuous set of tests (called validation tests) specified by the U.S. Government. Language differences from one Ada compiler to another are so few as to be noticeable only to a very knowledgeable user of Ada (more on this in Chapter 2).

Exercise for Section 1.5

Self-Check

  1. What do you think the high-level language statements below mean?
        X := A + B + C 
        X := Y / Z 
        D := C - B + A 
    


Previous | Next | Table of Contents | Index | Program List | Copyright

Copyright © 1996 by Addison-Wesley Publishing Company, Inc.