home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog1 / intro.txt < prev    next >
Encoding:
Text File  |  1991-07-01  |  12.3 KB  |  293 lines

  1.  
  2.  
  3.  
  4.                                                      Introduction
  5.  
  6.  
  7. Welcome to the world of Ada, a relatively new programming language
  8. with the force of the United States Department of Defense behind
  9. it.  Even though Ada will, in many cases, be mandated by the
  10. government for certain projects, it is a powerful enough language
  11. that it would probably be successful in the marketplace if it were
  12. left to compete on its own.
  13.  
  14.  
  15.  
  16. ADA IS A VERY LARGE LANGUAGE
  17. _________________________________________________________________
  18.  
  19. By its very nature, Ada is a large language that is relatively
  20. difficult to compile because it does so many checks at compile
  21. time.  It has been estimated that a fully validated Ada compiler
  22. requires about 50 man years to write and debug.  This is an
  23. indication that there will not be a plethora of Ada compilers, and
  24. they will not be small, easy to use programs, as a Pascal or a C
  25. compiler can be.  In addition, the Department of Defense requires
  26. any implementation that is called Ada, to be a complete system. 
  27. No subsets are allowed.
  28.  
  29. Due to the great size of the Ada language, this tutorial will be
  30. divided into two parts.  Beginning Ada will cover most of the
  31. essentials of Ada, and will instruct you in the use of Ada in much
  32. the same way that you would use Pascal.  If you complete only part
  33. 1, you will be able to write useful programs in Ada, but you will
  34. lack the elegance of the advanced features of Ada which are covered
  35. in Part 2 (Advanced Ada) of this tutorial.  Since Ada was intended
  36. to be a large, flexible language, it would be well for you to
  37. complete both parts of this tutorial.
  38.  
  39.  
  40.  
  41. ADA IS NOT JUST ANOTHER LANGUAGE
  42. _________________________________________________________________
  43.  
  44. Ada was developed to be more than just another programming
  45. language, since it embodies many of the modern principles of
  46. software engineering.  For example, the concept of information
  47. hiding is designed into the language, rather than being implemented
  48. as a programming technique.  Ada was also designed for developing
  49. large software systems, and is therefore applicable for use in
  50. programs containing hundreds of thousands, or even millions of
  51. lines of source code.  It is obvious that a single person could not
  52. write such a large program in a reasonably short time, a team
  53. effort being required to complete it.  Ada is especially well
  54. suited for use in a team environment.
  55.  
  56.  
  57.  
  58.                                                          Page I-1
  59.  
  60.                                                      Introduction
  61.  
  62. HOW IS THIS TUTORIAL WRITTEN?
  63. _________________________________________________________________
  64.  
  65. A good reference manual and a good tutorial are mutually exclusive
  66. entities, a reference manual being terrible for learning the
  67. material, and a tutorial being very poor as a reference following
  68. the learning cycle.  This tutorial is written as a tutorial, and
  69. no effort was given toward making it a reference manual.  It is
  70. therefore imperative that the student studies the lessons in the
  71. order given in the tutorial.  Many new concepts, as taught in this
  72. tutorial, use concepts illustrated earlier, and the earlier
  73. concepts must be understood in order to push profitably ahead.  
  74.  
  75. The example programs are all complete programs that can be compiled
  76. and executed on any computer with a validated Ada compiler.  None
  77. of the example programs are fragments, so you have a complete
  78. program before you with all of the code needed to execute each new
  79. concept as it is studied.
  80.  
  81.  
  82.  
  83. WHAT IF YOU DON'T HAVE AN ADA COMPILER?
  84. _________________________________________________________________
  85.  
  86. Following the code for each example program, you will find a list
  87. of the results, in the form of Ada comments, that were obtained by
  88. executing the program with a validated Ada compiler.  Actually, at
  89. least five different compilers were used on all of these files, so
  90. the results should be reliable.  The result of execution can be
  91. used for either of two purposes, the first being to check the
  92. output of your compiler for conformance to the standard, and the
  93. second being to give you the execution result if you don't have an
  94. Ada compiler.  Occasionally, you may wish to see the results
  95. without actually going through the compile, link, load, and run
  96. steps, so the listed output can be a time saver in those cases.
  97.  
  98. Every attempt was made to illustrate good programming practice with
  99. every example program, with the exception of two programs that are
  100. intended to show poor programming practice.  As you study the
  101. example programs in this tutorial, you will therefore be developing
  102. a good programming style through observation.
  103.  
  104.  
  105.  
  106. WHO WAS THIS TUTORIAL WRITTEN FOR?
  107. _________________________________________________________________
  108.  
  109. This tutorial was written especially for two groups of programmers,
  110. those with expertise in FORTRAN, and those with expertise in a
  111. modern structured language such as Pascal, C, or Modula-2.  A
  112. person with little or no programming experience will have a
  113. difficult time working his way through this tutorial because of the
  114. size and complexity of Ada, but with enough patience, even this
  115. person can learn Ada with the use of this tutorial.
  116.  
  117.                                                          Page I-2
  118.  
  119.                                                      Introduction
  120.  
  121.  
  122. The first group probably consists of mature programmers, those that
  123. have been in industry for many years and have been using FORTRAN
  124. for a large number of those years.  This author is a member of this
  125. group, having begun programming in FORTRAN II in 1961.  The
  126. experienced FORTRAN programmer will find the concept of the data
  127. type to be a new and seemingly troublesome addition to a
  128. programming language, so careful attention is paid to explaining
  129. the details of this concept and other concepts that would be new
  130. to him.
  131.  
  132. The second group would consist of those programmers that have
  133. experience with a modern structured language, such as Pascal, and
  134. already understand the concept of the data type, but find the newer
  135. additions to Ada totally foreign.  This author is also a member of
  136. this second group, having programmed in Pascal, C, C++, and
  137. Modula-2 exclusively for about eight years now, with Ada being
  138. added to the list about four years ago.
  139.  
  140.  
  141.  
  142. WHICH GROUP ARE YOU?
  143. _________________________________________________________________
  144.  
  145. If you are an experienced FORTRAN programmer, you will need nearly
  146. all of the details given in each chapter, but if you are of the
  147. modern structured language school, you will only need a small part
  148. of the details in some of the chapters, and can therefore read them
  149. very quickly.  A word of caution is in order however, because some
  150. of the details seem to be very much like Pascal but in reality are
  151. very different, so it would pay to look closely at even those
  152. things that you are already proficient with.
  153.  
  154. The experienced C programmer will probably be a bit frustrated with
  155. the attention to details required by the Ada compiler.  You will
  156. not have your favorite "tricks" available to fool the compiler into
  157. doing something out of the ordinary.  The Ada compiler cannot be
  158. fooled.
  159.  
  160.  
  161. THE PROGRAMMING EXERCISES
  162. _________________________________________________________________
  163.  
  164. One or more programming exercises are given at the end of each
  165. chapter for your benefit and instruction.  Each exercise is chosen
  166. to force you to exercise your new knowledge immediately upon
  167. completing the chapter at hand, and should be completed before
  168. continuing on to the next chapter.  If you do the exercises, you
  169. will gain experience in writing Ada, rather than simply reading
  170. Ada, and your overall comprehension will be greatly improved.  You
  171. will gain much knowledge simply by understanding the compiler error
  172. messages you receive during compilation.  You can be assured that
  173. you will get compiler error messages.  Some of the exercises even
  174. tell you to try something to see if you get an error message.
  175.  
  176.                                                          Page I-3
  177.  
  178.                                                      Introduction
  179.  
  180.  
  181. Answers to all of the programming exercises are given in the
  182. ANSWERS directory of the source disk.  The file naming format is
  183. CHnn_ml.ADA, with "nn" referring to the chapter number, "m"
  184. referring to the specific exercise from that chapter, and the "l"
  185. indicating that more than one answer is given.  The answer to
  186. programming exercise number 1 from chapter 4 would be in the file
  187. named CH04_1.ADA, and if there were two answers they would be in
  188. the files named CH04_1A.ADA and CH04_1B.ADA and each would have it
  189. own results in comments.  It would be to your advantage to attempt
  190. the exercises before you look at these files.  These files can be
  191. compiled and executed, but due to their nature, they may have
  192. compile or runtime errors in them since they are meant to
  193. illustrate some of the problems you can have.  The results of
  194. compiling and running them will be reported at the end of the files
  195. in comments in much the same way that the example programs are
  196. commented.
  197.  
  198. Some of the programming exercises have been carefully chosen to
  199. illustrate a few additional topics to augment the material taught
  200. in the chapter itself.  You may find yourself a bit confused at
  201. times, so you should go directly to the supplied answer file for
  202. clarification and help in solving the problem.  You should spend
  203. a little time trying to solve the problem yourself first.
  204.  
  205.  
  206.  
  207. YOUR OWN EXERCISES
  208. _________________________________________________________________
  209.  
  210. Many of the example programs do not produce any output.  This has
  211. been done on purpose to force you to write some output statements
  212. to see some of the results.  You should work from a backup copy of
  213. the distribution disk, and purposely corrupt some of the programs,
  214. attempting to do strange things to see if you understand the
  215. material covered in the text.  One of the initial requirements of
  216. this tutorial, as outlined at the outset of this project, was that
  217. all of the example programs would be compilable without error.
  218. This makes it difficult to illustrate some of the compiler checks,
  219. so it is up to you to see these errors yourself.  If the error is
  220. introduced by you, the compiler error message should be easily
  221. decipherable by you.  Keep in mind that some of the answers to the
  222. programming exercises will have compile or runtime errors.
  223.  
  224. As in all endeavors, you will get out of this tutorial as much as
  225. you are willing to put into it.
  226.  
  227.  
  228. RECOMMENDED READING LIST
  229. _________________________________________________________________
  230.  
  231. The following books are recommended to be studied in the given
  232. order.  All three books should be obtained if you plan to study Ada
  233. very seriously.
  234.  
  235.                                                          Page I-4
  236.  
  237.                                                      Introduction
  238.  
  239.  
  240. 1.   Barnes, J. G. P.;  "Programming In Ada, Third Edition",
  241.      Addison-Wesley.  This book defines the language at the lowest
  242.      level but teaches no software engineering.  This is the best
  243.      book for the new student to study to begin using Ada.  It is
  244.      best described as a reference manual for the Ada programming
  245.      language.
  246.  
  247. 2.   American National Standard reference manual for the Ada
  248.      programming language; ANSI/MIL-STD-1815A-1983.  This is the
  249.      definition of the Ada language as sponsored by the Department
  250.      of Defense.  It is often referred to as the Ada Language
  251.      Reference Manual (LRM) in the literature.  It is extremely
  252.      thorough, but remarkably easy to read after you have gained
  253.      at least some insight into the Ada language. It can be ordered
  254.      from;
  255.  
  256.           American National Standards Institute, Inc.
  257.           1430 Broadway,
  258.           New York, NY 10018
  259.  
  260.           The price as of this printing is $15.00 + $4.00 P & H.
  261.  
  262. 3.   Booch, Grady; "Software Engineering with Ada, Second Edition",
  263.      Benjamin Cummings.  This book assumes you have a fair grasp
  264.      of Ada and/or programming in general, and leads you into the
  265.      use of Ada for a large project with a plurality of
  266.      programmers.  It is an excellent book to study software
  267.      engineering, but a poor choice to begin with.
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.                                                          Page I-5