Translate

Search This Blog

Total Pageviews

Tuesday, November 13, 2018

Simplicity by Design: Pascal

All imperative languages owe some of their design to ALGOL60 and/or ALGOL 68.

                             Historical Background

Niklaus Wirth (Wirth is pronounced “Virt”) was a member of the International Federation of Information Processing (IFIP) Working Group 2.1, which was created to continue the development of ALGOL in the mid-1960s.

In August 1965, Wirth and C. A. R. (“Tony”) Hoare contributed to that effort by presenting to the group a somewhat modest proposal for additions and modifications to ALGOL 60 (Wirth and Hoare, 1966).
The majority of the group rejected the proposal as being too small an  improvement over ALGOL 60. Instead, a much more complex revision was developed, which eventually became ALGOL 68.

Wirth, along with a few other group members, did not believe that the ALGOL 68 report should have been released, based on the complexity of both the language and the metalanguage used to describe it. This position later proved to have some validity because the ALGOL 68 documents, and therefore the language, were indeed found to be challenging by the computing community.

The Wirth and Hoare version of ALGOL 60 was named ALGOL-W. It was implemented at Stanford University and was used primarily as an instructional vehicle, but only at a few universities.
The primary contributions of ALGOL-W were the value-result method of passing parameters and the case statement for multiple selection. The value-result method is an alternative to ALGOL 60’s pass-by-name method
Wirth’s next major design effort, again based on ALGOL 60, was his most successful: Pascal (Pascal is named after Blaise Pascal, a seventeenth-century French philosopher and mathematician who invented the first mechanical adding machine in 1642 (among other things).

The original published definition of Pascal appeared in 1971 (Wirth, 1971). This version was modified somewhat in the implementation process and is described in Wirth (1973).
The features that are often ascribed to Pascal in fact came from earlier languages. For example,
  • user-defined data types were introduced in ALGOL 68, 
  • the case statement in ALGOL-W, and 
  • Pascal’s records are similar to those of COBOL and PL/I.

                                    Evaluation

The largest impact of Pascal was on the teaching of programming. In 1970, most students of computer science, engineering, and science were introduced to programming with Fortran, although some universities used PL/I, languages based on PL/I, and ALGOL-W.

By the mid-1970s, Pascal had become the most widely used language for this purpose. This was quite natural, because:
Pascal was designed specifically for teaching programming. 
It was not until the late 1990s that Pascal was no longer the most commonly used language for teaching programming in colleges and universities.

Because Pascal was designed as a teaching language, it lacks several features
that are essential for many kinds of applications.

  • The best example of this is the impossibility of writing a subprogram that takes as a parameter an array of variable length. 
  • Another example is the lack of any separate compilation capability. These deficiencies naturally led to many nonstandard dialects, such as Turbo Pascal.
  1. Pascal’s popularity, for both teaching programming and other applications, was based primarily on its remarkable combination of simplicity and expressivity.  
  2. Although there are some insecurities in Pascal, it is still a relatively safe language, particularly when compared with Fortran or C.
By the mid-1990s, the popularity of Pascal was on the decline, both in industry and in universities, primarily due to the rise of Modula-2, Ada, and C++, all of which included features not available in Pascal.

The following is an example of a Pascal program:
{Pascal Example Program
Input: An integer, listlen, where listlen is less than
100, followed by listlen-integer values
Output: The number of input values that are greater than
the average of all input values }
program pasex (input, output);
type intlisttype = array [1..99] of integer;
var
    intlist : intlisttype;
    listlen, counter, sum, average, result : integer;
begin
    result := 0;
    sum := 0;
    readln (listlen);
   if ((listlen > 0) and (listlen < 100)) then
       begin
           { Read input into an array and compute the sum }
            for counter := 1 to listlen do
                 begin
                     readln (intlist[counter]);
                      sum := sum + intlist[counter]
                 end;{ Compute the average }
             average := sum / listlen;
            { Count the number of input values that are > average }
             for counter := 1 to listlen do
                 if (intlist[counter] > average) then
                     result := result + 1;
            { Print the result }
             writeln ('The number of values > average is:', result)
             end { of the then clause of if (( listlen > 0 ... }
 else
      writeln ('Error—input list length is not legal')
end.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.