Ch. 0 - 2 Ch. 0 - 2 1 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages Dr. Carter Tiernan.

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

Intermediate Code Generation
Programming Languages and Paradigms
INSTRUCTION SET ARCHITECTURES
Fortran Jordan Martin Steven Devine. Background Developed by IBM in the 1950s Designed for use in scientific and engineering fields Originally written.
1 Compiler Construction Intermediate Code Generation.
Names and Bindings.
The Assembly Language Level
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
MacLennan Chapter 1 The Beginning: Pseudo-code Interpreters.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists:
Introduction to Fortran Fortran Evolution Drawbacks of FORTRAN 77 Fortran 90 New features Advantages of Additions.
Chapter 8 . Sequence Control
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
6/27/2015G. Levine1 PROGRAMMING LANGUAGES Text: Programming Languages, Design and Implementation Pratt and Zelkowitz 4 th ed. Prentice-Hall.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Chapter 9: Subprogram Control
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
Compiler Construction A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University Second Semester 2008/2009.
JavaScript, Third Edition
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Reduced Instruction Set Computers (RISC) Computer Organization and Architecture.
MT311 Java Application Programming and Programming Languages Li Tak Sing ( 李德成 )
5.3 Machine-Independent Compiler Features
Introduction to FORTRAN
2.2 A Simple Syntax-Directed Translator Syntax-Directed Translation 2.4 Parsing 2.5 A Translator for Simple Expressions 2.6 Lexical Analysis.
CH13 Reduced Instruction Set Computers {Make hardware Simpler, but quicker} Key features  Large number of general purpose registers  Use of compiler.
Simple Procedural Languages: FORTRAN and C Lecture 9: Dolores Zage.
1 Programming Languages B.J. Maclennan 2. Fortran: Emphasis on Efficiency.
Compiler Construction
Programming Languages The Beginning. In the beginning... Computers were very expensive; programmers were cheap Programming was by plugboards or binary.
1 Names, Scopes and Bindings Aaron Bloomfield CS 415 Fall
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
FORTRAN FORmula TRANslator -Anand Trivedi. HISTORY  Designed and written from scratch in by an IBM team lead by John W. Backus as the first.
Introduction to Computer Programming Using C Session 23 - Review.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
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.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
FORTRAN History. FORTRAN - Interesting Facts n FORTRAN is the oldest Language actively in use today. n FORTRAN is still used for new software development.
Ch. 5 Ch. 51 jcmt Summer 2003Programming Languages CSE3302 Programming Languages (more notes) Summer 2003 Dr. Carter Tiernan.
By Mr. Muhammad Pervez Akhtar
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
1 Structure of Compilers Lexical Analyzer (scanner) Modified Source Program Parser Tokens Semantic Analysis Syntactic Structure Optimizer Code Generator.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
Computer Organization Instructions Language of The Computer (MIPS) 2.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Operational Semantics (Slides mainly.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (n-n-n-notes) Summer 2003 Dr. Carter Tiernan.
1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan.
Code Generation Instruction Selection Higher level instruction -> Low level instruction Register Allocation Which register to assign to hold which items?
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Functional Programming
CSE3302 Programming Languages (notes continued)
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
Representation, Syntax, Paradigms, Types
课程名 编译原理 Compiling Techniques
FORTRAN 04 February 1999; CS655.
Chapter 6 Intermediate-Code Generation
Representation, Syntax, Paradigms, Types
Representation, Syntax, Paradigms, Types
UNIT V Run Time Environments.
Languages and Compilers (SProg og Oversættere)
Representation, Syntax, Paradigms, Types
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Presentation transcript:

Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages Dr. Carter Tiernan

Ch Ch jcmt CSE 3302 Programming Languages programming language any a language that is intended for the expression of computer programs and is capable of expressing any computer program Ais

Ch Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming Languages Principles Open the front cover of your textbook. Yes, right now.

Ch Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming Languages Input and Output Based on I/O devices and methods of the time –Punched cards –Paper tape –Keyboards {Not much to say about this one}

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

Ch Ch jcmt CSE 3302 Programming Languages Interpreter enhancements Program tracing –Breakpoints –Data trap Labels for statements and variables –Beginning of symbol table Translation

Ch Ch jcmt CSE 3302 Programming Languages Symbolic Pseudo Code Syntax Punch cards led to fixed format fields Key punches only had upper case VAR format Prefix notation

Ch Ch jcmt CSE 3302 Programming Languages Phenomenology Ampliative and Reductive Fascination and Fear Direct vs. Mediated (transparency) Focus and Action

Ch Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 name ( input & output parameters ) – FUNCTION name ( input parameters )

Ch Ch jcmt CSE 3302 Programming 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 –Compare with pass by value-result Activation records save state

Ch Ch jcmt CSE 3302 Programming Languages Fortran: Activation Record Nonrecursive subprogram invocation Contains all data needed to activate or restart a subprogram –Parameters –Instruction pointer (resumption address) –Dynamic link –Temporary storage

Ch Ch jcmt CSE 3302 Programming Languages Fortran: Data Structures Scalars - integers, floating point –Integers, Hollerith constants (strings) –Double precision, complex, logical (boolean) Representation –Word-based –Appropriate to operations on the type Mathematical operations – Representation-independent –Overloaded for each type

Ch Ch jcmt CSE 3302 Programming Languages Fortran: Data Structures Arrays Contiguous memory allocation for indexing –Column-major order 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming Languages Fortran: 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming Languages Fortran syntax Fixed-format columns –Free-format statement in columns Ignored blanks (ugh!) No “reserved” words Allowed (quasi) algebraic notation Operator precedence Linear instruction sequence

Ch Ch jcmt CSE 3302 Programming 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 Ch jcmt CSE 3302 Programming 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