Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan.

Similar presentations


Presentation on theme: "1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan."— Presentation transcript:

1 1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan

2 2 jcmt Summer 2003Programming Languages programming language a language that is intended for the expression of computer programs and is capable of expressing any computer program Ais Ch. 0

3 3 jcmt Summer 2003Programming Languages Why is this interesting? Although it’s possible to write any program in any language, it’s not equally easy to do so. Languages are the tools of the central activity of computer science The structure of language defines the boundaries of thought Motivation for and use of modern language facilities Ch. 0

4 4 jcmt Summer 2003Programming Languages Why is this useful? Learning language mechanisms can allow you to simulate such things even in a language that does not provide them Presents the most important principles for the design, evaluation, and implementation of programming languages Ch. 0

5 5 jcmt Summer 2003Programming Languages Principles Open the front cover of your textbook. Yes, right now. Ch. 0

6 6 jcmt Summer 2003Programming Languages Early computing Numeric programming with coding of instructions A “pseudo-code” was a primitive language that implemented the machine code operations with different, and hopefully easier to use, codes –interpreted or –(eventually) compiled Ch. 1

7 7 jcmt Summer 2003Programming Languages Constraints Very slow Very small memory Computer time cost more than programmer time For numeric programming - –Significant floating point calculations –Requirement for indexing data Ch. 1

8 8 jcmt Summer 2003Programming Languages What must a “pseudo-code” (or a programming language) do? Originally based on what the actual machine could do: Floating point arithmetic and comparisons Indexing Transfer of control I/O Ch. 1

9 9 jcmt Summer 2003Programming Languages Decisions to make (OK, just a few of them) Syntax? How large can addresses be? How long can instructions be? How should we code the operations? and so on… Ch. 1

10 10 jcmt Summer 2003Programming Languages The Principles (again) Identify elements most important to good programming language design Apply with flexibility Balance among contradictory Modeled on Strunk and White Ch. 1

11 11 jcmt Summer 2003Programming Languages Arithmetic vs. Comparison Calculate values Use operands Values created can be used or stored Test values Use operands Test results can be used or stored Test results may control program flow Ch. 1

12 12 jcmt Summer 2003Programming Languages Moving, Indexing & Looping [ Addresses ] Moving –Put a value into a memory address Indexing –Access a single element from a multiple element structure - an array Looping –Change the flow of the program back to a previous location Ch. 1

13 13 jcmt Summer 2003Programming Languages Input and Output Based on I/O devices and methods of the time {Not much to say about this one;) } Ch. 1

14 14 jcmt Summer 2003Programming Languages Program Structure Declarations Instructions Input data Interpreter Execution 1.Read instruction 2.Decode 3.Execute 4.Repeat steps with next instruction Ch. 1

15 15 jcmt Summer 2003Programming Languages Interpreter enhancements Program tracing –Breakpoints –Data trap Labels for statements and variables –Beginning of symbol table Translation Ch. 1

16 16 jcmt Summer 2003Programming Languages Symbolic Pseudo Code Syntax Punch cards led to fixed format fields Key punches only had upper case VAR format Prefix notation Ch. 1

17 17 jcmt Summer 2003Programming Languages phenomenology Ampliative and Reductive Fascination and Fear Direct vs. Mediated (transparency) Focus and Action Ch. 1

18 18 jcmt Summer 2003Programming Languages Efficiency : Fortran Inclusion of floating point arithmetic and indexing in hardware exposed the overhead of interpreters John Backus of IBM recognized that language adoption would be based on : –Use of conventional mathematical notation –Highly efficient (machine) code produced Ch. 2

19 19 jcmt Summer 2003Programming Languages Adoption and Use of Fortran Development of a usable Fortran took 2 years (18 person/years) of effort (starting in 1955) Within a year and a half, approximately half the code being written for the IBM 704 machines was in Fortran Why? – Exceptionally clear documentation – Very sophisticated optimization techniques Many versions exist and are in use Book focuses on ANS Fortran IV (’66) Ch. 2

20 20 jcmt Summer 2003Programming Languages Fortran structure Subprograms –Parameters –COMMON blocks Declarative or Imperative (nonexecutable vs. executable) –Allocate, bind and initialize at declaration –Compute, control flow, or I/O Stages and phases of compilation Ch. 2

21 21 jcmt Summer 2003Programming Languages Imperative statements Assignment (=) is most important and most common computational statement Control structures developed to direct control to primitive statements –Structures were based on IBM 704 branches – GOTO used to transfer control with IF for selection and iteration – DO loop is only higher level construct Counted loop with CONTINUE Can be nested hierarchically Ch. 2

22 22 jcmt Summer 2003Programming Languages Fortran Control Issues Static and dynamic structure hard to see and correlate Confusion of GOTO plethora Weak typing DO-loop is optimized with all needed info for execution stated at the top Procedural abstraction  SUBROUTINE Ch. 2

23 23 jcmt Summer 2003Programming Languages Subroutines in Fortran CALL passes parameters and control RETURN passes control back to caller Allows modularity and encourages libraries Parameters passed by reference for efficiency but with side effects Activation records save state Ch. 2

24 24 jcmt Summer 2003Programming Languages Declarative statements Data Structures –Scalars and arrays Scalars - integers, floating point –double precision, complex, logical (boolean) Representation –Word-based –Appropriate to operations on the type Operations – representation-independent Ch. 2

25 25 jcmt Summer 2003Programming Languages Arrays Contiguous memory allocation for indexing Easy to optimize –Loop controls used array address to start –Subscript format was restricted –Index register increment easy to determine A(1) A(2) A(3) A(4) Ch. 2

26 26 jcmt Summer 2003Programming Languages Fortran Data Issues Overloaded operators Integer type used for integers and character strings (Hollerith constants) No facilities for character manipulation Arrays are static –Dimensions must be constants –Limited to 3 dimensions Ch. 2

27 27 jcmt Summer 2003Programming Languages Name structures Declaration does binding DATA statement does initialization Static allocation Fortran would automatically declare previously-unseen variables –“I through N” names assumed as integer – Major typo problems created Variable names are local scope Subprogram names are global scope Ch. 2

28 28 jcmt Summer 2003Programming Languages COMMON blocks Data sharing between subprograms Subprogram explicitly calls out the COMMON block to be used Aliasing EQUIVALENCE Share memory within a subprogram Ch. 2

29 29 jcmt Summer 2003Programming Languages Language Definition Lexics –The way characters are combined to form words and symbols Syntax –The way words and symbols are combined to form statements and expressions Lexical analysis (scanning) Syntactic analysis (parsing) Ch. 2

30 30 jcmt Summer 2003Programming Languages Fortran syntax Fixed-format columns –Free-format statement in columns 7 - 72 Ignored blanks (ugh!) No “reserved” words Allowed (quasi) algebraic notation Operator precedence Linear instruction sequence Ch. 2

31 31 jcmt Summer 2003Programming Languages First Generation Languages Machine dependence –Especially seen in control structures –And in primitive data types supported Non-nested and rely on GOTO One parameter passing mode Definite loops supported but not recursion Arrays Weak typing Static allocation and disjoint scoping of names Linear organization Ch. 2

32 32 jcmt Summer 2003Programming Languages Language Design Issues Interaction of features “Higher level” construct allows programmer to state what they want rather than how to do it “Regular” flow of control “Cost” of choices, e.g. Fortran efficiency Ch. 2


Download ppt "1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan."

Similar presentations


Ads by Google