THE ADA COMPUTER PROGRAMMING LANGUAGE

1. ORIGINS OF ADA

In the early 1970s the US Department of Defence (probably the largest user of computers in the world), conducted a study into the cost of developing and maintaining programs. During this study it emerged that over 450 languages were in use to develop software for the department. As a result (and in response to the software crisis) the department set up a working group (c1975) to identify a single programming language that would meet all the department's software needs. The aim was standardise on a single language, particularly with respect to real-time embedded systems. However, no existing language met the desired requirements. Consequently, to further its ends the Department organised an international design competition to develop a programming language that would meet the requirements. This was won by a group from CII-Honeywell Bull of France headed by Jean Ichbiah. Ichbiah's language was called "Green", however, the language in its final form was called Ada after Ada, Countess of Lovelace, who worked on Babbage's Analytical Engine and is considered by many to be the first programmer.

Ada was originally standardised by ANSI (American National Standards Institute) in 1983. ISO (International Standards Organisation) released an equivalent standard in 1987. Ada was recently revised to add some new capabilities (by a small team led by Tucker Taft); this revision is called `Ada 9X' or `Ada 95'.

Ada continues to receive support from the US Department of Defence, and as long as this continues its wide usage will be assured. There is U.S. legislation mandating Ada's use in Department of Defence software development projects (with various exceptions and waiver provisions). The strongest criticism of the language is Tony Hoare's ACM Turing Lecture entitled "The Emperor's Old Clothes" (Hoare 1981), in which he suggests that Ada is far too big and complex. The designers of Ada have subsequently retorted with a statement to the effect that real world problems are big and complex!


2. ANATOMY OF AN ADA PROGRAM

Below is a frame work for simple Ada programs.

with ... ;
use ... ;

procedure PROGRAM_NAME is
        <DATA_DECLARATION>
begin
        <CODE STATEMENT>
end PROGRAM_NAME;

Bold text indicates reserved words that have a special meaning. Note that when writing your own programs it is not necessary to emphasis different words in this way.

In Ada a program consists of a procedure. The procedure commences with the reserved word procedure and ends with the reserved word end. Good programming practice dictates that the end word be followed by a repeat of the procedure name. Statements are generally terminated by a semicolon (;). The with reserved word is used to introduce the library files, referred to as packages in Ada, to be "linked in". The use reserved word tells the compiler to search in the library files for any special program statements that we might want to include in our source code, for example to achieve terminal input and output. The procedure itself comprises two parts - a head and a body. The head contains details of the data declarations required by the procedure, and the body the code statements.


3. EXAMPLE PROBLEM SUM AND PRODUCT


3.1. Requirements

To build a program that takes two integers (X and Y) as input, and outputs their sum and product.


3.2 Design

We will commence the design process with a top down analysis of the problem. To this end we can identify the operations illustrated by the following hierarchical problem breakdown.

TOP DOWN ANALYSIS

At the highest level we have a single top level operation whose purpose is to combine the lower level procedures. At the second level (level 2) we can identify three distinct operations:

  1. Input values for X and Y
  2. Calculate and output sum
  3. Calculate and output procedure

A single procedure will be sufficient to implement these operations. We will call the procedure SUM_AND_PROD. It is usually useful to list the procedures that a program is going to use together with a brief description of what each procedure is intended to accomplish and the nature of the data items to be used. The latter is best achieved using a tabular format. Thus:

  1. SUM_AND_PROD (top level procedure): Input data, and calculate and output sum.
    NAMEUSAGETYPERANGE
    X_VALUEInput argumentINTEGERDefault
    Y_VALUEInput argumentINTEGERDefault
NASSI_SHNEIDERMAN CHART

Having identified the operations required to address a problem and the nature of the procedures the next stage is to design the algorithms whereby the procedures can be realised. We will do this using a Nassi-Shneiderman chart. An appropriate algorithm is presented in the N-S chart to the right. This design includes two variables X_VALUE and Y_VALUE. Both are integers. Note, in the N-S chart the procedure is entered at the top and exited from the bottom. The design comprises four distinct operations.


3.3. Implementation

Implementation is a direct, uncomplicated, encoding of the design given in the N-S chart.

-- SUM AND PRODUCT
-- 15 August 1997
-- Frans Coenen
-- Dept Computer Science, University of Liverpool

with CS_IO;
use CS_IO;

procedure SUM_AND_PROD is
        X_VALUE, Y_VALUE: INTEGER;
begin
        PUT_LINE("Give two whole numbers! ");
        GET(X_VALUE);
        GET(Y_VALUE);
-- Calculate sum
        PUT("The sum of the numbers is: ");
        PUT(X_VALUE+Y_VALUE);
        NEW_LINE;
-- Calculate product
        PUT("The product of the numbers is: ");
        PUT(X_VALUE*Y_VALUE);
        NEW_LINE;
end SUM_AND_PROD;

With respect to the implementation given above the following should be noted: