home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / PASTUT34 / ADA&C.TXT next >
Text File  |  1993-06-12  |  5KB  |  123 lines

  1.              PASCAL AND ITS RELATION TO OTHER LANGUAGES.
  2.              ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  3.  
  4. It has already been indicated that Pascal was developed from Algol, in
  5. as much as it is a structured, typed language using free-format. Other
  6. languages have retained these features, whilst attempting to improve on
  7. weaknesses.
  8.  
  9. In the 1970s, it was recognised that the difficulty of producing programs
  10. seemed to increase with the square of the program length (not linearly)
  11. and this led to the concept of modularization to reduce the difficulty
  12. and hence the cost of programs. The Turbo Pascal Unit illustrates this
  13. concept.  The language MODULA, amongst others, is another example of
  14. modularization, whilst Ada (1980) was the winner of a language design
  15. competition initiated by a working group for the US Department of
  16. Defense.
  17.  
  18. In Ada, expressions, statements and types are very similar to Pascal
  19. but the declaration part is different, particularly as regards 'package'
  20. and 'task', both of which declare modules.  Tasks are distinguished from
  21. packages in their ability to execute concurrently with other tasks.
  22.  
  23. Ada also uses a fully bracketed syntax, so that the different compound
  24. structures have distinguishable starts and finishes, instead of the
  25. standard 'begin' and 'end' of Pascal. Typical examples are:
  26.  
  27.     loop...end loop
  28.     if...end if
  29.     case...end case
  30.     record...end record
  31.  
  32. The main disadvantage to Ada is its size, coupled to the fact that the
  33. US Department of Defense will not allow a subset of the language, on
  34. the grounds that this would mitigate against portability.  This could
  35. well limit the use of this language, even though it will undoubtedly
  36. influence the developers of future languages.
  37.  
  38. Further information on Ada and other languages such as FORTRAN, Algol,
  39. Pascal, LISP, Smalltalk and PROLOG can be found in 'Principles of
  40. Programming Languages' by Bruce J. MacLennan, published by Holt,
  41. Rinehart and Winston (1983).
  42.  
  43. Perhaps the most attractive alternative language to a Pascal programmer
  44. is C. It is a structured, typed language with free-format, but unlike
  45. Ada it is a very small language.  It was developed by Dennis Ritchie at
  46. the Bell Laboratories in 1972, and was based on another language called
  47. B, itself derived from BCPL (Basic Combined Programming Language).
  48.  
  49. The language C is associated with the operating system UNIX, which is
  50. recommended by government and much used by universities.  Both UNIX and
  51. the C compiler are designed for portability.  Although UNIX itself
  52. requires a larger memory than the 640KB of ordinary PCs, UNIX (or XENIX)
  53. could well become the operating system of the future for 386 machines
  54. with 4 MB of memory.
  55.  
  56. C is a very flexible language, because any program is composed of
  57. functions which can be easily modified and extended and then stored on
  58. disk for use by other programs.
  59.  
  60. Although the syntax of C is different to Pascal, the style is similar
  61. and all statements are terminated by semi-colons (;).  Braces, { and },
  62. are used to indicate the start and end of the statements within a
  63. function, instead of the begin and end used in Pascal.  Comments are
  64. placed within /* and */ instead of the braces used in Pascal.
  65.  
  66. As with Pascal, control loops eliminate the need to use GOTO statements.
  67. They are similar to Turbo Pascal as indicated below:
  68.  
  69.     if (expression) statement1; else statement2;
  70.  
  71.     while (expression) statement;
  72.  
  73. or in the case of compound statements
  74.  
  75.     while (expression)
  76.           {
  77.            statement1;
  78.            ...
  79.            statementr;
  80.           }
  81.  
  82.     for(expression1; expression2; expression3) statement;
  83.  
  84.           where expression1 relates to the initial condition                                         expression2 relates to the end condition
  85.            and  expression3 act as the adjuster or counter.
  86.  
  87. There is also a 'Switch-Case' statement similar to the Case statement in
  88. Pascal.
  89.  
  90. Each function, including an obligatory one called 'main', must have open
  91. and closing brackets following the function name,  e.g.  main() and then
  92. have braces enclosing the statements of that function.  The brackets may
  93. enclose parameters, but must still be used even if there are no
  94. parameters.
  95.  
  96. The data types in C are:
  97.  
  98.          int    float    char    short    long    double
  99.  
  100. These are declared as shown below:
  101.  
  102.          int a,b,c;
  103.          char z;
  104.          etc.
  105.  
  106. Unsigned integers, arrays and pointers may also be used.  The size and
  107. precision of data types is machine dependent.  Assignments are indicated
  108. with the equal sign only (=), whilst == indicates 'equal to'.
  109.  
  110. There are a number of other operators, such as ++ which is used to
  111. increment a variable, so that ++a means a = a + 1 . % is used for
  112. modulus, whilst && means logical and.
  113.  
  114. Appropriate references should be consulted for further details, but for
  115. a modest text that enables a Pascal programmer to convert to C, 'The Big
  116. Red Book of C' by Kevin Sullivan, published by Sigma Press (1983) is
  117. recommended.  The definitive text is 'C Programming Language 2nd Ed.'
  118. by Kernighan and Ritchie, published by Prentice-Hall.
  119.  
  120.  
  121. ADA&C.TXT
  122. 1.3.90
  123.