1 / 38

David Evans cs.virginia/~evans

Lecture 12: All About Algol.

tave
Download Presentation

David Evans cs.virginia/~evans

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 12: All About Algol Algol60 was appreciated, almost immediately, as a rounded work of art. ... While Algol60 was no intellectual revolution, it was to become a universal tool with which to view, study and proffer solutions to almost every kind of problem in computation. Rarely has a construction so useful and elegant emerged as the output of a committee of 13 meeting for about 10 days.Alan Perlis, 1978 David Evans http://www.cs.virginia.edu/~evans CS655: Programming Languages University of Virginia Computer Science

  2. Menu • PS2, PS3 • Algol Background • Evolution of Algol Procedures • Ambiguities in Algol60 [Knuth] • Algol 68 University of Virginia CS 655

  3. PS2 Comments • Everyone got the quantum scheme interpreter to mostly work – good job! • No one wrote one elegantly or concisely enough to get 10/10, or to be worth handing out as solutions (although some came close). • No one used deeplistmerge in their solution! University of Virginia CS 655

  4. PS2 Comments • This isn’t a software engineering course, if it were I would be appalled at the test cases everyone used! • Test cases should always cover: • Error cases (observe failures) • Boundary cases (empty quists, singletons, etc.) University of Virginia CS 655

  5. PS3: Out Today • Pick an interesting target • Don’t pick C++ unless you have something creative to say (way too easy) • Best paper will convince me about a language I like (C, CLU, FL, Scheme) • Write well • Make a web page for a humanities grad student University of Virginia CS 655

  6. Communications of the ACM University of Virginia CS 655

  7. Communications of the ACM University of Virginia CS 655

  8. Communications of the ACM University of Virginia CS 655

  9. Communications of the ACM University of Virginia CS 655

  10. Communications of the ACM University of Virginia CS 655

  11. Before Algol • Ad hoc syntax descriptions, didn’t pay much attention • Operational language descriptions • Machine/compiler specific University of Virginia CS 655

  12. IBM 704 Fortran manual, 1956 University of Virginia CS 655

  13. Some Fortran Code • Loops DO 10 I=1.10 Assigns 1.10 to the variable DO10I DO 10 I=1,10 Loops for I = 1 to 10 (Often blamed for loss of Mariner-I, but probably not true.) University of Virginia CS 655

  14. Procedures in Fortran • Original “Programmer’s Reference Manual” [1956] – no way to define a function; could call pre-defined functions • Revised in 1957: • Define a function on a single line, with arguments • Call-by-reference: SUBROUTINE INCR(I) I = I + 1 RETURN END CALL INCR (2) N = 2 + 2 University of Virginia CS 655

  15. Algol Background • 1955: GAMM (European association of applied mathematics and mechanics) sets up committee to study development of a universal machine-independent programming language • May 1957: ACM forms committee to study universal programming language • October 4, 1957: University of Virginia CS 655

  16. 1958 • Oct 1957: agree to joint effort • 1958: Preliminary Report – International Algebraic Language. Objectives: • As close as possible to standard mathematical notation, readable with little further explanation • Useable for describing computing processes in publications • Mechanically translatable into machine programs University of Virginia CS 655

  17. Algol 58 University of Virginia CS 655

  18. Zürich Report (1959) • Removed distinction between functions and procedures: allow procedures to return a value, blocks • Separate input and output parameter lists procedure F (Pi0, Pi1, ...) =: (Pp0, Pp1, ...) • Can list parameter as both input and output • Procedure call by text replacement, replace return to go to to statement after procedure • Didn’t support recursion (proprosal to add recursive delimiter rejected) University of Virginia CS 655

  19. Algol 60 Committee • Committee consisting of 7 Europeans and 6 Americans (William Turanski died) • Europeans wanted a language to use • Americans using Fortran, other languages, etc. “It is probably true to say that the collective knowledge of the total group of participants in the development of Algol 60 included all there was to be known about programming languages at the time.” [Naur 78] John Backus (Fortran), Alan Perlis (first Turing award), Peter Naur (ACM President), John McCarthy (LISP) University of Virginia CS 655

  20. Three Languages • Reference Language • For use by committee, described in report and used in official Algol publications • Publication Language • Variations on reference language for publication, close correspondence to reference language • Hardware Representations • Condensed languages for machine input University of Virginia CS 655

  21. Why three languages? “After two days of probing attitudes and suggestions, the meeting came to a complete deadlock with one European member pounding on the table and declaring: “No! I will never use a period for a decimal point”. Naturally the Americans considered the use of comma as decimal point to be beneath ridicule. That evening Wegstein visited the opposing camps and proposed defining the three levels of language.” Alan Perlis, The American Side of the Development of Algol, ACM SIGPLAN Noticies, August 1978. University of Virginia CS 655

  22. Algol60 Procedures • Call-by-value or call-by-name determined by specifications • Removed need for distinction between input and output parameters • Defined by text replacement: • Value: additional block, local variables assigned to parameter • Name: replace throughout body enclosed parameter in parentheses “whenever syntactically possible” • Modified body inserted in place of call University of Virginia CS 655

  23. Jensen’s Device real procedure InnerProduct (z, y,n, j); value n; integer n; begin real a; a := 0; for j = 1 step 1 until n do a := a + z * y; InnerProduct := a end Sample calls: InnerProduct (A[i], B[i], 10, i) InnerProduct (M1[i,i], M2[k,i], 10, i) University of Virginia CS 655

  24. Call: InnerProduct (A[i], B[i], 10, i) begin real a; a := 0; for i = 1 step 1 until 10 do a := a + A[i] * B[i]; InnerProduct := a end Call: InnerProduct (M1[i,i], M2[k,i], 10, i) begin real a; a := 0; for i = 1 step 1 until 10 do a := a + M1[i,i] * M2[k, i]; IP := a end University of Virginia CS 655

  25. Ambiguity 1: Side Effects • If side effects are permitted, order of evaluation matters! begin integer a; integer procedure double(n) value n; integer n; double := n := n * 2; a := 2; outint (a * double(a) * double(a)); end. • Question: Have modern languages resolved this? University of Virginia CS 655

  26. Ambiguity 3: For Loops • Overly general and complicated • What were they (over) reacting to? • Semantics defined by formal translation (but they probably didn’t really mean it) for V := A step B until C do S  V := A; L1: if (V – C) * sign(B) > 0 then go todone; S; V := V + B; go toL1; University of Virginia CS 655

  27. Ambiguity 4: Specifications • 5.4.5: “Specifications (type declarations) of formal parameters called by value must be supplied and specifications of formal parameters called by name may be omitted.” (I don’t understand Knuth’s confusion.) • What are the advantages and disadvantages of not specifying call-by-name parameters? University of Virginia CS 655

  28. Ambiguity 8: Numeric Labels <label> ::= <identifier> | <unsigned integer> begin integer val; val := 7 go to val; 7: val := 8; go to val; comment yikes! val: … end University of Virginia CS 655

  29. Correction 1: if/else definition “The construction else <unconditional statement> is equivalent to elseif true then <unconditional statement>” (4.5.3.2) LISP (before Algol 60): (cond (p1 e1) (p2 e2) ... (pn en)) Go from left to right, first pi that is true, value is ei; If no pi is true, value of expression is undefined University of Virginia CS 655

  30. Influence of Algol 1954 FORTRAN 1960 Algol60 Classes CPL Algol68 Committee Simula67 PL/I BCPL Algol-W 1970 Algol68 Smalltalk Pascal C CLU Modula-2 1980 C++ Oberon Modula-3 Java 2000 University of Virginia CS 655

  31. Algol 68 Committee • Unruly, political, infighting, unresolved conflicts • 1965 Meeting: two proposals • Wirth and Hoare: extend Algol 60 with records • van Wijngaarden: design new language, minimal concepts combined in orthogonal way, describe using W-grammar, incomplete and incomprehensible • Kept postponing meetings because drafts weren’t ready • Accepted report (18 of 28 original members) • First implementation: 1970 • Revised Report: 1975 (first readable presentation) University of Virginia CS 655

  32. Othogonality in Design m*n things n Combination Techniques m Building Blocks Some of those m*n things will be hard to understand or implement, so you end up with either exceptions or complexity. University of Virginia CS 655

  33. Orthogonality in Algol68 • References ref x was a type, so refref x was a type. refs for parameters, so refs for local varaibles. • Procedures procs for parameters, so proc variables, parameters, results and in-line constructors • Compare to Pascal: “References are dangerous and complicated, so only allow them where they are absolutely necessary.” • Functions can only return simple types, passed procedures cannot have ref parameters, etc. University of Virginia CS 655

  34. W-Grammars • Invented by Van Wijngaarden • Can describe any computable language! (Contrast BNF: only context-free languages) Simplified example: reference to MODE assignation :: reference to MODE destination, :=, MODE source. MODE :: real ; integral ; reference to MODE; … University of Virginia CS 655

  35. Minority Report • Signed by Edsger Dijkstra, C. A. R. Hoare and 5 others • Some complaints about complexity of language (reference concept taken too far) • Many complaints about description of language (complexity of W-Grammars) • Controversy over publication (suppressed by IFIP) • Copy on your manifest University of Virginia CS 655

  36. Doomed to Failure Algol 68 • Published first report • 75 Published revised report • “one of the most unreadable documents which has ever been printed” • “Algol 68 with Fewer Tears” • Tanenbaum’s Tutorial • (See Knuth’s quote on Manifest.) University of Virginia CS 655

  37. What things in Java did not come directly from Algol 60? • Garbage collection (Lisp [1959]) • Exceptions (CLU [1977] had better) • User-defined types, structs (Algol 68 had these “better” than Java) • Data abstraction (confused in Pascal, better in CLU) • Objects, Dynamic Dispatch (Simula [1967]) • Concurrency (Algol 68 had better (?)) University of Virginia CS 655

  38. Charge • Lots of reading to do... • Problem Set 3 • Read Gifford’s notes on Operational Semantics • Read about Algol68 if you have time • Pick your target and content for PS3 carefully... University of Virginia CS 655

More Related