The ALGOL FamilyCSE341Programming Languages
Overview   Historical perspective   ALGOL Goals   BNF (Backus-Naur Form)   ALGOL 58   ALGOL 60   ALGOL 68   Success...
History   ALGOrithmic Language   Developed in Europe by an international group,    consisting of 7 different countries, ...
History (Continued)   Never became as commercially popular as FORTRAN    or COBOL       Was not compatible with IBM   I...
ALGOL Goals   To be as close as possible to standard math notation      Also very readable without much more explanation...
BNF (Backus-Naur Form)   Was first to use BNF (Backus-Naur Form)      Same Backus that created Fortran          He also...
Three Language Versions   Reference language      Used by the committee, described in the report, and used in       offi...
ALGOL 58The beginning   June 1957 – ACM requested a committee to    look into a universal programming language   Europea...
ALGOL 58New Features   Types     Integer     Real     Boolean   Formal vs Actual parameters   Declaration   for sta...
ALGOL 58Function vs Procedure   Nature of the body      Expression      Compound statement   Parameter evaluation mech...
Call by name vs. by value   Call by name is default   Call by name: re-evaluate the actual parameter on every    use    ...
Call by namebegin  integer n;  procedure p (k: integer)   parameter is n+10 (not just 10)     begin       print (k);      ...
Example   Computing Illustrate ( Compute The Mean ):    // the main program (this is a comment)    begin            integ...
Example(Continued)   I/O Illustrate: because ALGOL had no IO facilities. The following    code could run on an ALGOL impl...
Problems with Algol58   Didn’t include a I/O library     Thus, each implementation had a different      means for I/O   ...
ALGOL 60   Basic Language of 1960     Simple imperative language + functions     Successful syntax, BNF -- used by many...
ALGOL 60Proposed Changes   The empty statement was adopted   Modifications to operation hierarchy      Unary operators ...
ALGOL 60What’s New   Block   Call by value/name   Typed procedures   Declaration scope   Dynamic arrays   Side effec...
Algol 60 Samplereal procedure average(A,n);  real array A; integer n;                       no array bounds  begin       r...
Algol Oddity   Question:      Is x := x equivalent to doing nothing?   Interesting answer in Algol       integer proced...
Problems with Algol60   Holes in type discipline      Parameter types can be arrays, but          No array bounds     ...
ALGOL 68   Considered difficult to understand       Idiosyncratic terminology            Types were called “modes”     ...
ALGOL 68What’s New modesMany new types, called        Primatives             Bits             Bytes             Strin...
Algol 68 ModesPrimitive modes      Compound   Modes int                --arrays Real               --structures Char   ...
Other Features of Algol 68   Storage management      Local storage on stack      Heap storage and garbage collection  ...
Structure   ALGOL68 is block structured w/ static scope rules   ALGOL68s model of computation:       static       stac...
Basic Syntax   Addition : “ + ”   Subtraction : “ - ”   Multiplication : “ * ”   Division : “ / ”   Exponentiation : ...
Recursion   Algol 68 Supports recursion    Example:        real procedure factorial (n);        begin           if n = 1 ...
Arrays   Three types of arrays: real, integer, Boolean   Each array must contain all the same types   All arrays are of...
Block Structure   First language to implement a block structure   Similar in form to pascal    begin      …..    end;  ...
Block Structure example   Example:    begin      own integer i; integer j,k;      i := j + k;    end;        The integer...
Parameter Passing   Two types of parameter passing: by Value, by Name   Pass by Value works the same as in most other la...
ALGOLSuccesses and Failures   Programming computers – Partial Success       Core language is strong, no I/O is a serious...
Conclusion   General purpose algorithmic language with a clean    consistent and unambiguous syntax.   Comprehensive ful...
Conclusion (Continued)   Dynamic sized arrays know their current bounds.   Array and structure displays can be used in a...
References   Lindsey, C.H., “A History of ALGOL 68.” History of Programming    Languages, ACM Press. 1993. 97-132   Naur...
Upcoming SlideShare
Loading in...5
×

ALGOL ailesi programlama dilleri

624

Published on

Hamid Yeşilyayla, ödev

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
624
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

ALGOL ailesi programlama dilleri

  1. 1. The ALGOL FamilyCSE341Programming Languages
  2. 2. Overview Historical perspective ALGOL Goals BNF (Backus-Naur Form) ALGOL 58 ALGOL 60 ALGOL 68 Success and Failure of ALGOL Conclusion
  3. 3. History ALGOrithmic Language Developed in Europe by an international group, consisting of 7 different countries, in the late 1950’s Very similar to FORTRAN Peter Naur and J.W. Backus worked on the project. Was the debut of the BNF syntax. Designed specifically for programming scientific computations
  4. 4. History (Continued) Never became as commercially popular as FORTRAN or COBOL  Was not compatible with IBM Is considered the most important programming language in terms of influence on later language development Many similar languages can (and are) referred to as “ALGOL-like”  JAVA, C, C++, Pascal, Ada, FORTRAN, etc.
  5. 5. ALGOL Goals To be as close as possible to standard math notation  Also very readable without much more explanation Should be possible to use it to describe algorithms in publications  A form of it is still used today Should be mechanically translatable into machine language programs
  6. 6. BNF (Backus-Naur Form) Was first to use BNF (Backus-Naur Form)  Same Backus that created Fortran  He also was one of the main creators of Algol  And he created functional programming  And won the Turing award in ’77  Right. Back to BNF  BNF example:  <value> := <number> | <variable> | <expression>  <number> := <integer> | <float>  <integer> := <integer><digit> | <digit>  <digit> := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Language was designed by committee Report is a “paradigm of brevity and clarity”  Most languages today require 1000’s of pages  Brevity and clarity contributed to reputation as simple, elegant language
  7. 7. Three Language Versions Reference language  Used by the committee, described in the report, and used in official Algol publications Publication language  Allowed for differences in the character set for different languages  Europeans and Americans couldn’t decide on which character to use for the decimal point! Hardware representations  Condensed languages for machine input
  8. 8. ALGOL 58The beginning June 1957 – ACM requested a committee to look into a universal programming language European and American groups got together in Zurich.  No current language covers everything  Creating more non-ideal languages doesn’t help the situation  Each passing month more people start using other languages  How can the logical structure of existing languages be adjusted
  9. 9. ALGOL 58New Features Types  Integer  Real  Boolean Formal vs Actual parameters Declaration for statements Switch Compound statements Begin end delimiters Three level language description Call by name
  10. 10. ALGOL 58Function vs Procedure Nature of the body  Expression  Compound statement Parameter evaluation mechanism  Value of any actual parameter  Text of any actual parameter Identifier collision  Non-parameter identifiers are global to the definition  Communication only through parameters Place of use  An operand in an expression  A statement or an operand in an expression
  11. 11. Call by name vs. by value Call by name is default Call by name: re-evaluate the actual parameter on every use  For actual parameters that are simple variables, it’s the same as call by reference  For actual parameters that are expressions, the expression is re-evaluated on each access No other language ever used call by name…
  12. 12. Call by namebegin integer n; procedure p (k: integer) parameter is n+10 (not just 10) begin print (k); prints n+10, which is 10 n := n+1; n is still 0; thus, n becomes 1 print (k); prints n+10, which is 11 end; n is set to 0 n := 0; parameter is n+10 (not just 10) p (n+10);end;
  13. 13. Example Computing Illustrate ( Compute The Mean ): // the main program (this is a comment) begin integer N; Read Int(N); begin real array Data[1:N]; real sum, avg; integer i; sum:=0; for i:=1 step 1 until N do begin real val; Read Real(val); Data[i]:=if val<0 then -val else val end; for i:=1 step 1 until N do sum:=sum + Data[i]; avg:=sum/N; Print Real(avg) end end
  14. 14. Example(Continued) I/O Illustrate: because ALGOL had no IO facilities. The following code could run on an ALGOL implementation for a Burroughs A- Series mainframe. BEGIN FILE F (KIND=REMOTE); EBCDIC ARRAY E [0:11]; REPLACE E BY "HELLO WORLD!"; WHILE TRUE DO BEGIN WRITE (F, *, E); END; END.
  15. 15. Problems with Algol58 Didn’t include a I/O library  Thus, each implementation had a different means for I/O  This caused compatibility problems  And no standard way to write a Hello World program
  16. 16. ALGOL 60 Basic Language of 1960  Simple imperative language + functions  Successful syntax, BNF -- used by many successors  statement oriented  begin … end blocks (like C { … } )  if … then … else Recursive functions and stack storage allocation  Type discipline was improved by later languages  Very influential but not widely used in US Tony Hoare: “Here is a language so far ahead of its time that it was not only an improvement on its predecessors but also on nearly all of its successors.”
  17. 17. ALGOL 60Proposed Changes The empty statement was adopted Modifications to operation hierarchy  Unary operators having higher precedence than binary operators was adopted  Implied multiplication was rejected  Relation sequences were rejected The else clause was adopted Strings, lists, trees, matrices, and complex numbers were rejected as types Multiple assignment statements were adopted  Created a new problem, A[i] := i := e Recursion became possible in obvious ways Constants were rejected
  18. 18. ALGOL 60What’s New Block Call by value/name Typed procedures Declaration scope Dynamic arrays Side effects Global and local variables Step, until, while, if then else Activation records Recursive decent parsers No I/O
  19. 19. Algol 60 Samplereal procedure average(A,n); real array A; integer n; no array bounds begin real sum; sum := 0; for i = 1 step 1 until n do sum := sum + A[i]; average := sum/n no ; here end; set procedure return value by assignment
  20. 20. Algol Oddity Question:  Is x := x equivalent to doing nothing? Interesting answer in Algol integer procedure p; begin …. p := p …. end;  Assignment here is actually a recursive call
  21. 21. Problems with Algol60 Holes in type discipline  Parameter types can be arrays, but  No array bounds  Parameter types can be procedures, but  No argument or return types for procedure parameters Problems with parameter passing mechanisms  Pass-by-name “Copy rule” duplicates code, interacting badly with side effects  Pass-by-value expensive for arrays Some awkward control issues  goto out of block requires memory management
  22. 22. ALGOL 68 Considered difficult to understand  Idiosyncratic terminology  Types were called “modes”  Arrays were called “multiple values”  Used vW grammars instead of BNF  Context-sensitive grammar invented by van Wijngaarden  Elaborate type system  Complicated type conversions Fixed some problems of Algol 60  Eliminated pass-by-name Not widely adopted
  23. 23. ALGOL 68What’s New modesMany new types, called  Primatives  Bits  Bytes  String  Sema (a semaphore)  Complex  File  Pipe  Channel  format  Additional  Flex (Flexible array)  Heap (space on the heap)  Loc (local space on the stack)  Ref (pointer)  Long (bigger ints/reals)  Short (smaller ints/reals) Declaration of custom types/modes
  24. 24. Algol 68 ModesPrimitive modes Compound Modes int --arrays Real --structures Char --procedures bool --sets string --pointers Compl(complex) bits bytes Rich, structured, and orthogonal type system is a major contribution Sema (semaphore) of Algol 68. Format (I/O) file
  25. 25. Other Features of Algol 68 Storage management  Local storage on stack  Heap storage and garbage collection Parameter passing  Pass-by-value  Use pointer types to obtain pass-by-reference Assignable procedure variables
  26. 26. Structure ALGOL68 is block structured w/ static scope rules ALGOL68s model of computation:  static  stack: block/procedure ARs; local data objects  heap: “heap” -- dynamic-- data objects ALGOL68 is an expression-oriented language
  27. 27. Basic Syntax Addition : “ + ” Subtraction : “ - ” Multiplication : “ * ” Division : “ / ” Exponentiation : “ ** ” Assignment : “ := ” Boolean Expressions  = , > , < , <= , >= , /=
  28. 28. Recursion Algol 68 Supports recursion Example: real procedure factorial (n); begin if n = 1 then factorial := 1; else factorial := n* factorial(n-1); end;
  29. 29. Arrays Three types of arrays: real, integer, Boolean Each array must contain all the same types All arrays are of type real unless specified Can have multidimensional arrays Declarations:  array name1[1:100]; (1D array of type real)  real array name2(-3:6,20:40); (2D array of type real)  integer array name3,name4(1:46);(2 1D arrays of type integer)  Boolean array name5(-10:n); (1D array of type Boolean) (Allocated Dynamically)
  30. 30. Block Structure First language to implement a block structure Similar in form to pascal begin ….. end; Each block can have its own variables, visible only to that block (local variables). After the block is exited the values of all the local variables are lost.
  31. 31. Block Structure example Example: begin own integer i; integer j,k; i := j + k; end;  The integer i will have the value of j+k stored the next time the block is entered By using the “own” statement the variable will retain its value for the next time the block is entered
  32. 32. Parameter Passing Two types of parameter passing: by Value, by Name Pass by Value works the same as in most other languages Pass by Name is similar to pass by reference, but it adds flexibility  All parameters are pass by name unless otherwise specified  Example: can make a call “sum(i,2,5,x+6)” to the procedure sum procedure sum(i,j,k,l); value i,j,k; begin i := i + j + k + l end; (will execute as i := i + 2 + 5 + (x+6))
  33. 33. ALGOLSuccesses and Failures Programming computers – Partial Success  Core language is strong, no I/O is a serious shortcoming Publication of algorithms – Very Successful Stimulus to compiler design – Success with a seed of corruption  It only stimulated compiler design because it was difficult Stimulated formal language research – Success  Not the goal of the ALGOL effort Description of ALGOL 60 – Failure  Difficult to understand for the uninitiated reader  Needs an informal explanation
  34. 34. Conclusion General purpose algorithmic language with a clean consistent and unambiguous syntax. Comprehensive fully-checked type-system covering structures, unions, pointers, arrays and procedures. Procedures may be nested inside procedures and can deliver values of any type without you having to worry about where the storage is coming from. User-defined operators including user-defined operator symbols. Powerful control structures can deliver values of any type.
  35. 35. Conclusion (Continued) Dynamic sized arrays know their current bounds. Array and structure displays can be used in any context. Parallel programming with semaphores. Complex arithmetic. Declarations can be interleaved with statements. Clear distinction between value semantics and reference semantics. No distinction between compile-time constants and run- time values.
  36. 36. References Lindsey, C.H., “A History of ALGOL 68.” History of Programming Languages, ACM Press. 1993. 97-132 Naur, Peter, “Successes and failures of the ALGOL effort”, ALGOL Bulletin #28, Computer History Museum. 1986. 58-62 Thomson, C.M., “Algol 68 as a Living Language”, ALGOL Bulletin #47, Computer History Museum. 1981. 21-24 Perlis, Alan, “The American side of the development of Algol”, The first ACM SIGPLAN conference on History of programming languages, ACM Press. 1978. 3-14 Naur, Peter. “The European side of the last phase of the development of ALGOL 60”, The first ACM SIGPLAN conference on History of programming languages, ACM Press. 1978. 15-44
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×