1 / 26

CSE3302 Programming Languages (notes continued)

CSE3302 Programming Languages (notes continued). Dr. Carter Tiernan. Generality and Hierarchy: Algol-60. Close as possible to standard mathematical notation and readable Usable for describing computing processes Mechanically translatable to machine language. A. B. D. C. Algol Design.

vanna
Download Presentation

CSE3302 Programming Languages (notes continued)

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. CSE3302Programming Languages(notes continued) Dr. Carter Tiernan Programming Languages

  2. Generality and Hierarchy:Algol-60 • Close as possible to standard mathematical notation and readable • Usable for describing computing processes • Mechanically translatable to machine language Programming Languages

  3. A B D C Algol Design • Hierarchical structure / Nesting • (unlike C & C++) • Declarative and Imperative constructs • Variable, procedure, and switch • Computational and control-flow • Compilation handled differently than Fortran • Stack for run-time structures Programming Languages

  4. A B D C Algol: Name Structures • Names are NOT statically bound • Block structure supports scoping • Blocks are compound statements with declarations • Scope - contour diagrams • Context • Inner blocks implicitly inherit access to variables in its immediately surrounding block Programming Languages

  5. Algol: Blocks • Allows shared data to be easily organized with the subprograms that need it (but does allow indiscriminate access) • Scoping choices • Static: called in the environment of its definition (used exclusively in Algol) • Dynamic: called in the environment of its caller Programming Languages

  6. Dynamic Scoping • Called in environment of caller • Can write general procedures that make use of variables and procedures supplied by caller’s environment • Vulnerable to being called from an environment without correct supporting procedures • Not generally used in current languages Programming Languages

  7. Static Scoping • Called in the environment of its definition • Requires the user to pass parameters of local environment • Cannot behave differently based on call location only • Ensures that the static structure of the program more closely agrees with the dynamic behavior of the program. Programming Languages

  8. A B D C D C A Algol: Stacks for management • Disjoint blocks allow conservation of memory on the stack • Assumption: a variable is retained only so long as the program is executing in the scope of that variable or in a block that will return to the scope of that variable • Blocks follow LIFO execution; ergo, a stack handles the activation records in a LIFO fashion Programming Languages

  9. Responsible Design • Understand the programmers’ problem • Provide a high quality solution • Which is not necessarily the solution the programmers (or users) asked for • Responsible Design Principle • Caveat: If the user wants it and you don’t supply it (in their fashion), they may not accept your alternate (even if better) solution Programming Languages

  10. Algol: Data Structures • Primitives are scalars • Boolean, integer, and real • No double precision because it’s machine dependent • No complex due to tradeoffs of usefulness vs. complexity • Limited string type that required procedures coded in some other language in order to be output or used Programming Languages

  11. Zero-One-Infinity Principle • Supports regularity - easier to learn, remember, and master • Eliminates arbitrary numerical limits • Applies to arrays in • Number of dimensions • Start and end values for indices Programming Languages

  12. Algol: Arrays • Generalized • Dynamic due to stack allocation Data Types • Strong typing • Coercions and conversions • Type system as “safety feature” Programming Languages

  13. Algol: Control structures • Primitives • Assignment := • No input/output - handled with library routines • Structures • Regularize the FORTRAN structures • if condition then statement1 else statement2 • for initialization keyword test do statement Programming Languages

  14. Algol: Control and nesting • All control structures can handle arbitrary number of bracketed statements • Compound statements formed with begin and end • Algol structuring led to Dijkstra’s letter, “GOTO Considered Harmful” Programming Languages

  15. Algol: More control • Hierarchical structure Structured programming • Recursion supported • Instantiation of locals • Every call creates a new activation record • Conditional expression Programming Languages

  16. Algol: Parameter passing • Passing by value • Local copy of parameter • Requires keyword value • Pass by name • Default mode • Based on substitution - Copy Rule • Not actually substituted for formal params Programming Languages

  17. Algol: Pass by name • Compare to pass by reference • Name parameters bound to string • Jensen’s device • Use pass by name with index variable to cycle through array elements • Implementation - thunk • Compile parameter • Pass address of compiled parameter code • Inconsistent behavior Programming Languages

  18. Language Design Issues • GO TO controversy • Conceptual models • System image • Feature interaction Programming Languages

  19. Algol: Control (more) • Out of block GO TOs • Levels of activation must be popped • For-loop • For-list-elements reevaluated every pass • Step, until • While • Enumerated list • All of the above • Baroque Programming Languages

  20. Algol: Control etal. • Switch declaration • Array of statement labels • Processes cases - not necessarily distinct • Best use recombines after cases • Difficult to correlate with dynamic structure • Baroque Programming Languages

  21. Algol: Syntactic Structures • Machine independent / portable • Free-format • Programmers had to think about how it should look • Reflect the structure of the program • Independent of character sets • Reference language • Publication language • Hardware representation Programming Languages

  22. Algol: Lexics • Lexical conventions • Reserved words • Keywords (Algol approach) • Keywords in context • Dangling else • Style Programming Languages

  23. Backus-Naur Form (BNF) • Precise programming language descriptions • English difficult to read • Examples incomplete • Perceptual clarity with precision • Backus - syntactic categories • Naur added improvements to notation • Metalanguage Programming Languages

  24. BNF • Terminals • Nonterminals • Defined in terms of nonterminals and terminals • Recursive definition allowed • Related to Chomsky language hierarchy • Context-free grammar • Regular (non-recursive) grammar Programming Languages

  25. Design Criteria • Efficiency - scientific issues • Minimize resources • Maximize safety • Economy - social issues • Maximize social benefit • Minimize cost • Elegance - aesthetic issues • Function follows form • Manifest interactions Programming Languages

  26. Second Generation Languages 2nd • Elaborations and generalizations of first generation languages • Stronger typing • Hierarchical structure • Blocks • Control flow • Recursion • Parameter passing modes • Free-format syntax • Machine independent conventions • Reserved word/ Keywords Programming Languages

More Related