CSE3302 Programming Languages (notes continued)

Slides:



Advertisements
Similar presentations
Intermediate Code Generation
Advertisements

Programming Languages and Paradigms
CS 415: Programming Languages Algol Aaron Bloomfield Fall 2005.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists:
Chapter 3 Describing Syntax and Semantics Sections 1-3.
Run time vs. Compile time
Chapter 3 Describing Syntax and Semantics Sections 1-3.
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
Chapter 9: Subprogram Control
Chapter 3 Describing Syntax and Semantics Sections 1-3.
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Programming Languages
CSE 341, S. Tanimoto Concepts 1- 1 Programming Language Concepts Formal Syntax Paradigms Data Types Polymorphism.
ALGOL-60 GENERALITY AND HIERARCHY
1 Programming Languages B.J. Maclennan 2. Fortran: Emphasis on Efficiency.
Programming Languages The Beginning. In the beginning... Computers were very expensive; programmers were cheap Programming was by plugboards or binary.
C H A P T E R TWO Syntax and Semantic.
Programming Languages and Paradigms Imperative Programming.
Ch. 5 Ch. 51 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (more notes) Dr. Carter Tiernan.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes, notes, notes) Dr. Carter Tiernan.
D Goforth COSC Translating High Level Languages Note error in assignment 1: #4 - refer to Example grammar 3.4, p. 126.
Ch. 5 Ch. 51 jcmt Summer 2003Programming Languages CSE3302 Programming Languages (more notes) Summer 2003 Dr. Carter Tiernan.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages Dr. Carter Tiernan.
C H A P T E R T W O Syntax and Semantic. 2 Introduction Who must use language definitions? Other language designers Implementors Programmers (the users.
Procedure Definitions and Semantics Procedures support control abstraction in programming languages. In most programming languages, a procedure is defined.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan.
Chapter 3 – Describing Syntax CSCE 343. Syntax vs. Semantics Syntax: The form or structure of the expressions, statements, and program units. Semantics:
Chapter 3 – Describing Syntax
Describing Syntax and Semantics
Data Types In Text: Chapter 6.
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
Describing Syntax and Semantics
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Principles ; P.F. Reynolds CS655.
Algol 60 John Cowan N Languages in N Months Meetup June 7, 2016
Chapter 3 – Describing Syntax
Representation, Syntax, Paradigms, Types
What does it mean? Notes from Robert Sebesta Programming Languages
Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
FORTRAN 04 February 1999; CS655.
CSC 533: Programming Languages Spring 2015
R.Rajkumar Asst.Professor CSE
Final Review In Text: Chapters 1-3, 5-10,
Representation, Syntax, Paradigms, Types
CSCE 330 Programming Language Structures Ch.2: Syntax and Semantics
Midterm Review In Text: Chapters 1-3, 5-10, 15.
Subprograms In Text: Chapter 9.
Final Review In Text: Chapters 1-3, 5-12,
Representation, Syntax, Paradigms, Types
Final Review In Text: Chapters 1-3, 5-16.
Representation, Syntax, Paradigms, Types
Chapter 3 Describing Syntax and Semantics.
BNF 9-Apr-19.
Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Final Review In Text: Chapters 1-3, 5-16.
Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Midterm Review In Text: Chapters 1-3, 5-11, 15.
Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
CSC 533: Programming Languages Spring 2018
Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
CSC 533: Programming Languages Spring 2019
Types and Related Issues
Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Presentation transcript:

CSE3302 Programming Languages (notes continued) Dr. Carter Tiernan CSE 3302 CSE@UTA Programming Languages

Generality and Hierarchy: Algol-60 Close as possible to standard mathematical notation and readable Usable for describing computing processes Mechanically translatable to machine language CSE 3302 CSE@UTA Programming Languages

Programming Languages B C D 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 CSE 3302 CSE@UTA Programming Languages

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 A B C D CSE 3302 CSE@UTA Programming Languages

Programming Languages 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 CSE 3302 CSE@UTA Programming Languages

Programming Languages 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 CSE 3302 CSE@UTA Programming Languages

Programming Languages 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. CSE 3302 CSE@UTA Programming Languages

Algol: Stacks for management B C D 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 D C A CSE 3302 CSE@UTA Programming Languages

Programming Languages 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 CSE 3302 CSE@UTA Programming Languages

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 CSE 3302 CSE@UTA Programming Languages

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 CSE 3302 CSE@UTA Programming Languages

Programming Languages Algol: Arrays Generalized Dynamic due to stack allocation Data Types Strong typing Coercions and conversions Type system as “safety feature” CSE 3302 CSE@UTA Programming Languages

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 CSE 3302 CSE@UTA Programming Languages

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” CSE 3302 CSE@UTA Programming Languages

Programming Languages Algol: More control Hierarchical structure Structured programming Recursion supported Instantiation of locals Every call creates a new activation record Conditional expression CSE 3302 CSE@UTA Programming Languages

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 CSE 3302 CSE@UTA Programming Languages

Programming Languages 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 CSE 3302 CSE@UTA Programming Languages

Language Design Issues GO TO controversy Conceptual models System image Feature interaction CSE 3302 CSE@UTA Programming Languages

Programming Languages 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 CSE 3302 CSE@UTA Programming Languages

Programming Languages 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 CSE 3302 CSE@UTA Programming Languages

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 CSE 3302 CSE@UTA Programming Languages

Programming Languages Algol: Lexics Lexical conventions Reserved words Keywords (Algol approach) Keywords in context Dangling else Style CSE 3302 CSE@UTA Programming Languages

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 CSE 3302 CSE@UTA Programming Languages

Programming Languages 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 CSE 3302 CSE@UTA Programming Languages

Programming Languages 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 CSE 3302 CSE@UTA Programming Languages

Second Generation Languages 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 2nd CSE 3302 CSE@UTA Programming Languages