


                                                     Introduction


Welcome to the world of Ada, a relatively new programming language
with the force of the United States Department of Defense behind
it.  Even though Ada will, in many cases, be mandated by the
government for certain projects, it is a powerful enough language
that it would probably be successful in the marketplace if it were
left to compete on its own.



ADA IS A VERY LARGE LANGUAGE
_________________________________________________________________

By its very nature, Ada is a large language that is relatively
difficult to compile because it does so many checks at compile
time.  It has been estimated that a fully validated Ada compiler
requires about 50 man years to write and debug.  This is an
indication that there will not be a plethora of Ada compilers, and
they will not be small, easy to use programs, as a Pascal or a C
compiler can be.  In addition, the Department of Defense requires
any implementation that is called Ada, to be a complete system. 
No subsets are allowed.

Due to the great size of the Ada language, this tutorial will be
divided into two parts.  Beginning Ada will cover most of the
essentials of Ada, and will instruct you in the use of Ada in much
the same way that you would use Pascal.  If you complete only part
1, you will be able to write useful programs in Ada, but you will
lack the elegance of the advanced features of Ada which are covered
in Part 2 (Advanced Ada) of this tutorial.  Since Ada was intended
to be a large, flexible language, it would be well for you to
complete both parts of this tutorial.



ADA IS NOT JUST ANOTHER LANGUAGE
_________________________________________________________________

Ada was developed to be more than just another programming
language, since it embodies many of the modern principles of
software engineering.  For example, the concept of information
hiding is designed into the language, rather than being implemented
as a programming technique.  Ada was also designed for developing
large software systems, and is therefore applicable for use in
programs containing hundreds of thousands, or even millions of
lines of source code.  It is obvious that a single person could not
write such a large program in a reasonably short time, a team
effort being required to complete it.  Ada is especially well
suited for use in a team environment.



                                                         Page I-1

                                                     Introduction

HOW IS THIS TUTORIAL WRITTEN?
_________________________________________________________________

A good reference manual and a good tutorial are mutually exclusive
entities, a reference manual being terrible for learning the
material, and a tutorial being very poor as a reference following
the learning cycle.  This tutorial is written as a tutorial, and
no effort was given toward making it a reference manual.  It is
therefore imperative that the student studies the lessons in the
order given in the tutorial.  Many new concepts, as taught in this
tutorial, use concepts illustrated earlier, and the earlier
concepts must be understood in order to push profitably ahead.  

The example programs are all complete programs that can be compiled
and executed on any computer with a validated Ada compiler.  None
of the example programs are fragments, so you have a complete
program before you with all of the code needed to execute each new
concept as it is studied.



WHAT IF YOU DON'T HAVE AN ADA COMPILER?
_________________________________________________________________

Following the code for each example program, you will find a list
of the results, in the form of Ada comments, that were obtained by
executing the program with a validated Ada compiler.  Actually, at
least five different compilers were used on all of these files, so
the results should be reliable.  The result of execution can be
used for either of two purposes, the first being to check the
output of your compiler for conformance to the standard, and the
second being to give you the execution result if you don't have an
Ada compiler.  Occasionally, you may wish to see the results
without actually going through the compile, link, load, and run
steps, so the listed output can be a time saver in those cases.

Every attempt was made to illustrate good programming practice with
every example program, with the exception of two programs that are
intended to show poor programming practice.  As you study the
example programs in this tutorial, you will therefore be developing
a good programming style through observation.



WHO WAS THIS TUTORIAL WRITTEN FOR?
_________________________________________________________________

This tutorial was written especially for two groups of programmers,
those with expertise in FORTRAN, and those with expertise in a
modern structured language such as Pascal, C, or Modula-2.  A
person with little or no programming experience will have a
difficult time working his way through this tutorial because of the
size and complexity of Ada, but with enough patience, even this
person can learn Ada with the use of this tutorial.

                                                         Page I-2

                                                     Introduction


The first group probably consists of mature programmers, those that
have been in industry for many years and have been using FORTRAN
for a large number of those years.  This author is a member of this
group, having begun programming in FORTRAN II in 1961.  The
experienced FORTRAN programmer will find the concept of the data
type to be a new and seemingly troublesome addition to a
programming language, so careful attention is paid to explaining
the details of this concept and other concepts that would be new
to him.

The second group would consist of those programmers that have
experience with a modern structured language, such as Pascal, and
already understand the concept of the data type, but find the newer
additions to Ada totally foreign.  This author is also a member of
this second group, having programmed in Pascal, C, C++, and
Modula-2 exclusively for about eight years now, with Ada being
added to the list about four years ago.



WHICH GROUP ARE YOU?
_________________________________________________________________

If you are an experienced FORTRAN programmer, you will need nearly
all of the details given in each chapter, but if you are of the
modern structured language school, you will only need a small part
of the details in some of the chapters, and can therefore read them
very quickly.  A word of caution is in order however, because some
of the details seem to be very much like Pascal but in reality are
very different, so it would pay to look closely at even those
things that you are already proficient with.

The experienced C programmer will probably be a bit frustrated with
the attention to details required by the Ada compiler.  You will
not have your favorite "tricks" available to fool the compiler into
doing something out of the ordinary.  The Ada compiler cannot be
fooled.


THE PROGRAMMING EXERCISES
_________________________________________________________________

One or more programming exercises are given at the end of each
chapter for your benefit and instruction.  Each exercise is chosen
to force you to exercise your new knowledge immediately upon
completing the chapter at hand, and should be completed before
continuing on to the next chapter.  If you do the exercises, you
will gain experience in writing Ada, rather than simply reading
Ada, and your overall comprehension will be greatly improved.  You
will gain much knowledge simply by understanding the compiler error
messages you receive during compilation.  You can be assured that
you will get compiler error messages.  Some of the exercises even
tell you to try something to see if you get an error message.

                                                         Page I-3

                                                     Introduction


Answers to all of the programming exercises are given in the
ANSWERS directory of the source disk.  The file naming format is
CHnn_ml.ADA, with "nn" referring to the chapter number, "m"
referring to the specific exercise from that chapter, and the "l"
indicating that more than one answer is given.  The answer to
programming exercise number 1 from chapter 4 would be in the file
named CH04_1.ADA, and if there were two answers they would be in
the files named CH04_1A.ADA and CH04_1B.ADA and each would have it
own results in comments.  It would be to your advantage to attempt
the exercises before you look at these files.  These files can be
compiled and executed, but due to their nature, they may have
compile or runtime errors in them since they are meant to
illustrate some of the problems you can have.  The results of
compiling and running them will be reported at the end of the files
in comments in much the same way that the example programs are
commented.

Some of the programming exercises have been carefully chosen to
illustrate a few additional topics to augment the material taught
in the chapter itself.  You may find yourself a bit confused at
times, so you should go directly to the supplied answer file for
clarification and help in solving the problem.  You should spend
a little time trying to solve the problem yourself first.



YOUR OWN EXERCISES
_________________________________________________________________

Many of the example programs do not produce any output.  This has
been done on purpose to force you to write some output statements
to see some of the results.  You should work from a backup copy of
the distribution disk, and purposely corrupt some of the programs,
attempting to do strange things to see if you understand the
material covered in the text.  One of the initial requirements of
this tutorial, as outlined at the outset of this project, was that
all of the example programs would be compilable without error.
This makes it difficult to illustrate some of the compiler checks,
so it is up to you to see these errors yourself.  If the error is
introduced by you, the compiler error message should be easily
decipherable by you.  Keep in mind that some of the answers to the
programming exercises will have compile or runtime errors.

As in all endeavors, you will get out of this tutorial as much as
you are willing to put into it.


RECOMMENDED READING LIST
_________________________________________________________________

The following books are recommended to be studied in the given
order.  All three books should be obtained if you plan to study Ada
very seriously.

                                                         Page I-4

                                                     Introduction


1.   Barnes, J. G. P.;  "Programming In Ada, Third Edition",
     Addison-Wesley.  This book defines the language at the lowest
     level but teaches no software engineering.  This is the best
     book for the new student to study to begin using Ada.  It is
     best described as a reference manual for the Ada programming
     language.

2.   American National Standard reference manual for the Ada
     programming language; ANSI/MIL-STD-1815A-1983.  This is the
     definition of the Ada language as sponsored by the Department
     of Defense.  It is often referred to as the Ada Language
     Reference Manual (LRM) in the literature.  It is extremely
     thorough, but remarkably easy to read after you have gained
     at least some insight into the Ada language. It can be ordered
     from;

          American National Standards Institute, Inc.
          1430 Broadway,
          New York, NY 10018

          The price as of this printing is $15.00 + $4.00 P & H.

3.   Booch, Grady; "Software Engineering with Ada, Second Edition",
     Benjamin Cummings.  This book assumes you have a fair grasp
     of Ada and/or programming in general, and leads you into the
     use of Ada for a large project with a plurality of
     programmers.  It is an excellent book to study software
     engineering, but a poor choice to begin with.

























                                                         Page I-5