Programming Languages: Design, Specification, and Implementation G22.2210-001 Rob Strom September 7, 2006.

Slides:



Advertisements
Similar presentations
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
Advertisements

Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
Copyright © 1998 by Addison Wesley Longman, Inc. 1 Chapter One Preliminaries, including –Why study PL concepts? –Programming domains –PL evaluation criteria.
CSI 3125, Preliminaries, page 1 Programming languages and the process of programming –Programming means more than coding. –Why study programming languages?
Computers Are Your Future
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Reasons to study concepts of PL
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Operational Semantics.
Programming Languages Structure
Introduction and Syntax. Course objectives Discuss features of programming languages. Discuss how the features are implemented in a simple computer architecture.
Summer 02-03Programming Language Concepts1 Programming Language Concepts (CS 360) Lecture 1: Overview, Grammars, and Little Languages Jeremy R. Johnson.
Programming Language Concepts
CS 415: Programming Languages Chapter 1 Aaron Bloomfield Fall 2005.
Overview. Copyright © 2006 The McGraw-Hill Companies, Inc. Chapter 1 Overview A good programming language is a conceptual universe for thinking about.
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
PZ01A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ01A -- Introduction Programming Language Design and.
CS 355 – Programming Languages
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
G Programming Languages T he main themes of programming language design and use: –Model of computation –Expressiveness types and their operations.
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
Programming Languages and Design Lecture 1 Introduction to Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern University,
Chapter 1. Introduction.
Therac 25 Nancy Leveson: Medical Devices: The Therac-25 (updated version of IEEE Computer article)
CS 363 Comparative Programming Languages
CS 330 Programming Languages 09 / 04 / 2008 Instructor: Michael Eckmann.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
1 Programming Languages Marjan Sirjani Course web site:
1 Programming Language History and Evolution In Text: Chapter 2.
1 Introduction Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Computer Concepts 2014 Chapter 12 Computer Programming.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming.
Chapter 6 Programming Languages (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Engr. Isabelo Jun D. Paat, ME-CoE Lecturer 1 Programming Languages.
PC204 Lecture 5 Programming Methodologies Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.
Programming Languages
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Introduction to Compilers Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY.
CSCI 3428: Software Engineering Tami Meredith Chapter 7 Writing the Programs.
C H A P T E R T H R E E Type Systems and Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
Programming Language Design Issues Programming Languages – Principles and Practice by Kenneth C Louden.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
MANAGING COMPLEXITY Lecture OO01 Introduction to Object-oriented Analysis and Design Abstract Data Types.
Introduction to Computer Programming using Fortran 77.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
Programming Paradigms, Software Architectural Patterns, and MVC CS 378 – Mobile Computing for iOS Dr. William C. Bulko.
Programming Language History and Evolution
Chapter 1. Introduction.
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Types for Programs and Proofs
PROGRAMMING LANGUAGES
课程名 编译原理 Compiling Techniques
Final Review In Text: Chapters 1-11,
Final Review In Text: Chapters 1-3, 5-10, 12,
Final Review In Text: Chapters 1-3, 5-10, 12,
Programming Languages 2nd edition Tucker and Noonan
Final Review In Text: Chapters 1-3, 5-16.
강의 내용 및 방법 접근방법 리포트 시험 Lambda Calculus, Proof of Correctness
Final Review In Text: Chapters 1-3, 5-16.
Presentation transcript:

Programming Languages: Design, Specification, and Implementation G Rob Strom September 7, 2006

Outline  Conceptual Background Requirements of Programming Languages Requirements of Programming Languages Specification vs. Implementation Specification vs. Implementation Syntax, Semantics, Types, Static Analysis Syntax, Semantics, Types, Static Analysis  Language Paradigms Imperative: FORTRAN, Cobol, Algol, Pascal, PL/I, C Imperative: FORTRAN, Cobol, Algol, Pascal, PL/I, C Applicative: LISP, Scheme, ML Applicative: LISP, Scheme, ML Object-oriented: Smalltalk, Java Object-oriented: Smalltalk, Java “Fourth-generation”: SETL, SQL “Fourth-generation”: SETL, SQL Logic Programming: Prolog Logic Programming: Prolog Concurrent-Distributed: Concurrent Pascal, Hermes Concurrent-Distributed: Concurrent Pascal, Hermes Languages vs. “Tools”/Patterns Languages vs. “Tools”/Patterns  Implementation Issues Compile time: parsing, type analysis, static checking Compile time: parsing, type analysis, static checking Run time: parameter passing, garbage collection, method dispatching, remote invocation, just-in-time compiling, parallelization Run time: parameter passing, garbage collection, method dispatching, remote invocation, just-in-time compiling, parallelization

Tentative Outline  Motivations, Universals  Fortran and Algol 60 models: recursion and the stack  Algol 68, parameter passing, PL/I, C, heap  Functional programming: Scheme  Formal type systems: ML  Object-oriented languages: objects, inheritance, C++  Ada: packages, generics  Patterns and Pitfalls in Imperative Languages  Logic Programming  4 th generation languages  Concurrency and Distribution: memory models,  Implementation issues

Readings  Main Text: David Gelernter and Suresh Jagannathan: “Programming Linguistics”, MIT Press, David Gelernter and Suresh Jagannathan: “Programming Linguistics”, MIT Press,  Secondary Texts Michael L. Scott: “Programming Language Pragmatics”, Academic Press, Michael L. Scott: “Programming Language Pragmatics”, Academic Press, Benjamin C. Pierce: “Types and Programming Languages”, MIT Press, 2002 Benjamin C. Pierce: “Types and Programming Languages”, MIT Press, 2002  Language References: Giannesini et al: “Prolog”, Addison-Wesley Giannesini et al: “Prolog”, Addison-Wesley Gosling et al: “The Java Language Specification”, Gosling et al: “The Java Language Specification”, Dewhurst & Stark, “Programming in C++”, Prentice Hall, Dewhurst & Stark, “Programming in C++”, Prentice Hall, Ada 95 Reference Manual, Ada 95 Reference Manual, MIT Scheme Reference MIT Scheme Reference Strom et al: “Hermes: A Language for Distributed Computing”, Prentice-Hall, Strom et al: “Hermes: A Language for Distributed Computing”, Prentice-Hall, Other sources: Other sources: R. Kent Dybvig, “The SCHEME Programming Language”, Prentice Hall, 1987.R. Kent Dybvig, “The SCHEME Programming Language”, Prentice Hall, Jan Skansholm, “ADA 95 From the Beginning”, Addison Wesley, 1997.Jan Skansholm, “ADA 95 From the Beginning”, Addison Wesley, 1997.

Grading  Programming Projects – 60%  Other required homework – 10%  Final examination – 30%

First 2 Lectures: Readings  Pierce, chapters 2, 3, 8 (formal operational semantics) (formal operational semantics) Optional exercises , Optional exercises ,  Scott, chapter 2, section 1 How do we define tokens and syntax How do we define tokens and syntax  Gelernter chapter 3, sections 1-2 Introduction to FORTRAN and Algol 60 Introduction to FORTRAN and Algol 60

Issues in Language Design  Dijkstra, “Goto Statement Considered Harmful”,  Backus, “Can Programming Be Liberated from the von Neumann Style?”  Hoare, “An Axiomatic Basis For Computer Programming”,  Hoare, “The Emperor’s Old Clothes”,  Parnas, “On the Criteria to be Used in Decomposing Systems into Modules”,

Scope  General purpose high-level programming languages  Excludes: Machine languages Machine languages Assembly languages Assembly languages “Scripting” languages “Scripting” languages Markup languages Markup languages Special purpose languages (e.g. report writing) Special purpose languages (e.g. report writing) Graphical languages Graphical languages

How do we judge languages?  Compactness – writability/expressibility  Readability – ease of validation  Familiarity of Model  Less Error-Prone  Portability  Hides Details – simpler model  Early detection of errors  Modularity – Reuse  Modularity – Composability  Modularity – Isolation  Performance Transparency  Optimizability

Program Specifications  What properties a solution will meet  E.g: Accept a list of input tuples looking like, where k is an integer and v is any string Accept a list of input tuples looking like, where k is an integer and v is any string Deliver a list of output tuples such that Deliver a list of output tuples such that If tuple appears n times in input, it appears n times in outputIf tuple appears n times in input, it appears n times in output If tuple appears n times in output, it appears n times in inputIf tuple appears n times in output, it appears n times in input For any two successive tuples and in output, k1 and in output, k1 <= k2 Provided (some restriction, e.g. max number/range of tuples) Provided (some restriction, e.g. max number/range of tuples)  Doesn’t necessarily say how to compute a solution, and preferably allows for many possible solutions  Usually more compact than an implementation

Language Specifications  Given a “program text” How to tell whether it is a valid expression in the language How to tell whether it is a valid expression in the language What it “means” as a specification or an implementation of a program What it “means” as a specification or an implementation of a program  Usually, also: How to take a “chunk” of a “program text” How to take a “chunk” of a “program text” How to determine what it means as a specification of a component How to determine what it means as a specification of a component How to put together the specifications of components to define the specification of the program How to put together the specifications of components to define the specification of the program

Universals  Syntax: lexical and syntactic levels  Naming: Defining and applied occurrences Defining and applied occurrences Scope Scope  Types  Semantics Operational Operational Denotational Denotational Algebraic Algebraic

$18.5 Million Bug (?) IF (TVAL.LT. 0.2E-2) GOTO 40 IF (TVAL.LT. 0.2E-2) GOTO 40 DO 40 M = 1, 3 DO 40 M = 1, 3 W0 = (M-1)*0.5 W0 = (M-1)*0.5 X = H* E-2*W0 X = H* E-2*W0 DO 20 N0 = 1, 8 DO 20 N0 = 1, 8 EPS = 5.0*10.0**(N0-7) EPS = 5.0*10.0**(N0-7) CALL BESJ(X, 0, B0, EPS, IER) CALL BESJ(X, 0, B0, EPS, IER) IF (IER.EQ. 0) GOTO 10 IF (IER.EQ. 0) GOTO CONTINUE DO 5 K = 1. 3 DO 5 K = 1. 3 T(K) = W0 T(K) = W0 Z = 1.0/(X**2)*B1** E-4*B0**2 Z = 1.0/(X**2)*B1** E-4*B0**2 D(K) = 3.076E-2*2.0*(1.0/X*B0*B E-4*(B0**2-X*B0*B1))/Z D(K) = 3.076E-2*2.0*(1.0/X*B0*B E-4*(B0**2-X*B0*B1))/Z E(K) = H**2* *W0/SIN(W0)*Z E(K) = H**2* *W0/SIN(W0)*Z H = D(K)-E(K) H = D(K)-E(K) 5 CONTINUE 10CONTINUE Y = H/W0-1 Y = H/W CONTINUE

2003 North American blackout  The XA/21 monitoring software runs on Unix and is made of of several subsysystems. According to hacker journalist Kevin Poulsen, the bug was a race condition in the one-million lines of C++ code that made up the event processing subsystem. Kevin PoulsenKevin Poulsen  According to Mike Unum, manager at GE Energy in Melbourne, Florida: “There was a couple of processes that were in contention for a common data structure, and through a software coding error in one of the application processes, they were both able to get write access to a data structure at the same time. And that corruption led to the alarm event application getting into an infinite loop and spinning.”

Therac-25 Radiation Therapy  Software bugs caused overdoses; 5 died The design did not have any hardware interlocks to prevent the electron-beam from operating in its high-energy mode without the target in place. The design did not have any hardware interlocks to prevent the electron-beam from operating in its high-energy mode without the target in place.interlocks The engineer had reused software from older models. These models had hardware interlocks that masked their software defects. Those hardware safeties had no way of reporting that they had been triggered, to at least indicate the existence of faulty software commands. The engineer had reused software from older models. These models had hardware interlocks that masked their software defects. Those hardware safeties had no way of reporting that they had been triggered, to at least indicate the existence of faulty software commands.reused The hardware provided no way for the software to verify that sensors were working correctly (see open-loop controller). The table-position system was the first implicated in Therac-25's failures; the manufacturer gave it redundant switches to cross-check their operation. The hardware provided no way for the software to verify that sensors were working correctly (see open-loop controller). The table-position system was the first implicated in Therac-25's failures; the manufacturer gave it redundant switches to cross-check their operation.open-loop controlleropen-loop controller The equipment control task did not properly synchronize with the operator interface task, so that race conditions occurred if the operator changed the setup too quickly. This was evidently missed during testing, since it took some practice before operators were able to work quickly enough for the problem to occur. The equipment control task did not properly synchronize with the operator interface task, so that race conditions occurred if the operator changed the setup too quickly. This was evidently missed during testing, since it took some practice before operators were able to work quickly enough for the problem to occur.tasksynchronizerace conditionstasksynchronizerace conditions The software set a flag variable by incrementing it. Occasionally an arithmetic overflow occurred, causing the software to bypass safety checks. The software set a flag variable by incrementing it. Occasionally an arithmetic overflow occurred, causing the software to bypass safety checks.flag variablearithmetic overflowflag variablearithmetic overflow The software was written in assembly language. While this was more common at the time than it is today, assembly language is harder to debug than most high- level languages. The software was written in assembly language. While this was more common at the time than it is today, assembly language is harder to debug than most high- level languages.assembly languageassembly language

BNF expr ::= expr “+” term | expr “–” term | term term ::= term “*” factor | term “/” factor | factor factor ::= number | identifier | “(“ expr “)”