Seminar in Programming Languages

Similar documents
(Advanced) topics in Programming Languages

CS 242. Fundamentals. Reading: See last slide

CS Computable Functions. Reading: Chapter 2

Programming Languages 2nd edition Tucker and Noonan"

Concepts of Programming Languages

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

Types and Type Inference

Topic I. Introduction and motivation References: Chapter 1 of Concepts in programming languages by J. C. Mitchell. CUP, 2003.

Types and Type Inference

Programming Languages, Summary CSC419; Odelia Schwartz

CSCI 3136 Principles of Programming Languages

Com S 541. Programming Languages I

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

Concepts in Programming Languages

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Types, Type Inference and Unification

What is a programming language?

Thanks! Review. Course Goals. General Themes in this Course. There are many programming languages. Teaching Assistants. John Mitchell.

CS383 PROGRAMMING LANGUAGES. Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University

A simple syntax-directed

Principles of Programming Languages [PLP-2015] Detailed Syllabus

What is programming? Elements of Programming Languages. From machine code to programming languages. What is a programming language?

CSc 520. Course Outline (Subject to change) Course Outline (Subject to change)... Principles of Programming Languages. Christian Collberg

MIDTERM EXAMINATION. CSE 130: Principles of Programming Languages. Professor Goguen. February 16, points total

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Programmiersprachen (Programming Languages)

CSCI.4430/6969 Programming Languages Lecture Notes

Programming Language Concepts

G COURSE PLAN ASSISTANT PROFESSOR Regulation: R13 FACULTY DETAILS: Department::

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

CMSC 330: Organization of Programming Languages. Administrivia

Outline. Programming Languages 1/16/18 PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY. Current

Concepts of Programming Languages

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

CS 360 Programming Languages Interpreters

11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations

CS 415 Midterm Exam Spring 2002

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

Lecture 1: Course Introduction

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

Compiler Theory. (Semantic Analysis and Run-Time Environments)

EI326 ENGINEERING PRACTICE & TECHNICAL INNOVATION (III-G) Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University

INSTITUTE OF AERONAUTICAL ENGINEERING

Recursive Functions of Symbolic Expressions and Their Computation by Machine Part I

Contents. Chapter 1 SPECIFYING SYNTAX 1

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106

cs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides.

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

Introduction. A. Bellaachia Page: 1

RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 96 INSTRUCTIONS

What Is Computer Science? The Scientific Study of Computation. Expressing or Describing

CSc 372 Comparative Programming Languages

Introduction to Scientific Computing Languages

Introduction to Scientific Computing Languages

PLAGIARISM. Administrivia. Course home page: Introduction to Programming Languages and Compilers

Introduction to Programming Languages and Compilers. CS164 11:00-12:00 MWF 306 Soda

SOFTWARE ARCHITECTURE 6. LISP

Functional Programming and Haskell

Language Translation, History. CS152. Chris Pollett. Sep. 3, 2008.

G Programming Languages Spring 2010 Lecture 1. Robert Grimm, New York University

Type Inference Systems. Type Judgments. Deriving a Type Judgment. Deriving a Judgment. Hypothetical Type Judgments CS412/CS413

Formal Semantics. Chapter Twenty-Three Modern Programming Languages, 2nd ed. 1

Why are there so many programming languages?

CMSC 330: Organization of Programming Languages

G Programming Languages - Fall 2012

INTRODUCTION PRINCIPLES OF PROGRAMMING LANGUAGES. Norbert Zeh Winter Dalhousie University 1/10

(Refer Slide Time: 4:00)

n Closed book n You are allowed 5 cheat pages n Practice problems available in Course Materials n Check grades in Rainbow grades

Weeks 6&7: Procedures and Parameter Passing

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

7. Introduction to Denotational Semantics. Oscar Nierstrasz

The role of semantic analysis in a compiler

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

Chapter 1. Preliminaries

Comp 333: Concepts of Programming Languages Fall 2016

Compiler Construction

Early computers (1940s) cost millions of dollars and were programmed in machine language. less error-prone method needed

Informatica 3 Syntax and Semantics

CS 3304 Comparative Languages. Lecture 1: Introduction

Chapter 1 Preliminaries

CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria

Chapter 1. Preview. Reason for Studying OPL. Language Evaluation Criteria. Programming Domains

Earlier edition Dragon book has been revised. Course Outline Contact Room 124, tel , rvvliet(at)liacs(dot)nl

COSC252: Programming Languages: Semantic Specification. Jeremy Bolton, PhD Adjunct Professor

Lecture content. Course goals. Course Introduction. TDDA69 Data and Program Structure Introduction Cyrille Berger

Outline. Introduction to Programming (in C++) Introduction. First program in C++ Programming examples

Programming Languages Third Edition

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures

Lecture 1: Course Introduction

Programming Language Concepts 1982, 1987, Outline. Period

Programming language design and analysis

CS 314 Principles of Programming Languages

Transcription:

Seminar in Programming Languages Shuly Wintner Fall 2010-11 Course web site: http://cs.haifa.ac.il/~shuly/teaching/10/plseminar/

Course Goals Programming Language Concepts A language is a conceptual universe (Perlis) Framework for problem-solving Useful concepts and programming methods Understand the languages you use, by comparison Appreciate history, diversity of ideas in programming Be prepared for new programming methods, paradigms, tools Critical thought Identify properties of language, not syntax or sales pitch Language and implementation Every convenience has its cost Recognize the cost of presenting an abstract view of machine Understand trade-offs in programming language design

Language goals and trade-offs Architect Programmer Tester Programming Language Diagnostic Tools Compiler, Runtime environment

What s new in programming languages Commercial trend over past 5 years Increasing use of type-safe languages: Java, C#, Scripting languages, other languages for web applications Teaching trends Java replaces C as most common intro language Less emphasis on how data, control represented in machine Research and development trends Modularity Java, C++: standardization of new module features Program analysis Automated error detection, programming env, compilation Isolation and security Sandboxing, language-based security, Web 2.0 Increasing client-side functionality, mashup isolation problems

What s worth studying? Dominant languages and paradigms C, C++, Java Imperative and Object-oriented languages Explosion of programming technologies for the web Important implementation ideas Performance challenges Concurrency Design tradeoffs Concepts that research community is exploring for new programming languages and tools

Organization of the course Traditional Algol, Pascal constructs Block structure, activation records Scope, control structures, function calls Types and type systems,... Lisp/Scheme concepts higher-order functions and closures, tail recursion exceptions, continuations Modularity and program structure Specific emphasis on OOP Smalltalk vs C++ vs Java Language design and implementation Concurrent and distributed programming

Languages in common use Compiled by François Labelle from statistics on open-source projects at SourceForge

Languages in common use From http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

Language groups Multi-purpose languages C, C++, Java Visual Basic Object Pascal: Delphi, Kylix, Lisp, Scheme, ML Scripting languages Perl, PHP, Python Shell Special-purpose languages SQL Prolog

Structure of the course Lisp (chapter 3) Foundations (chapter 4) ML/Algol language summary (chapter 5) Types and type inference (chapter 6) Scope, functions and storage management (chapter 7) Control in sequential languages (chapter 8) Modularity and data abstraction (chapter 9) Object-oriented languages (chapter 10) Simula and Smalltalk (chapter 11) C++ (chapter 12) Java (chapter 13) Concurrent and distributed programming (chapter 14) TBD

Methodology Read ahead You should read each chapter before it is presented Each session will be moderated by one student The moderator is responsible for running the show Presentation slides are available! Feel free to modify them as you see fit The material covered must follow the book chapter, not the slides

Administration Grade based on Comprehension and preparation of the chapter you moderate Preparation for other sessions Contribution to class discussion Office hours Wednesday 16:00-17:00, Jacobs 403. Phone: (828)8180. Assignment of chapters First come, first served

Fundamentals Shuly Wintner Slides courtesy of John C. Mitchell

Topics 14

Topics Computability and partial functions Compilers and syntax Lambda calculus (as an operational semantics) Denotational semantics Imperative vs. functional languages 14

Subtle: undefined is not the name of a function value

Foundations: Partial,Total Functions Subtle: undefined is not the name of a function value

Foundations: Partial,Total Functions Value of an expression may be undefined Undefined operation, e.g., division by zero 3/0 has no value implementation may halt with error condition Nontermination f(x) = if x=0 then 1 else f(x-2) this is a partial function: not defined on all arguments cannot be detected at compile-time; this is halting problem These two cases are Mathematically equivalent Operationally different Subtle: undefined is not the name of a function value

Partial and Total Functions f(x) g(x) Total function: f(x) has a value for every x Partial function: g(x) does not have a value for every x x

Partial and Total Functions f(x) g(x) Total function: f(x) has a value for every x Partial function: g(x) does not have a value for every x x

Functions and Graphs f(x) g(x) Graph of f = { x,y y = f(x) } Graph of g = { x,y y = g(x) } Mathematics: a function is a set of ordered pairs (graph of function) x

Partial and Total Functions Total function f:a B is a subset f A B with For every x A, there is some y B with x,y f If x,y f and x,z f then y=z (total) (single-valued) Partial function f:a B is a subset f A B with If x,y f and x,z f then y=z (single-valued) Programs define partial functions for two reasons partial operations (like division) nontermination f(x) = if x=0 then 1 else f(x-2)

Computability Definition Function f is computable if some program P computes it: For any input x, the computation P(x) halts with output f(x)

Halting function Decide whether program halts on input Given program P and input x to P, Halt (P,x) = yes if P(x) halts no otherwise Clarifications Assume program P requires one string input x Write P(x) for output of P when run in input x Program P is string input to Halt Fact: There is no program for Halt

Unsolvability of the halting problem Suppose P solves variant of halting problem On input Q, assume P(Q) = yes if Q(Q) halts Build program D no otherwise D(Q) = run forever halt if Q(Q) halts if Q(Q) runs forever Does this make sense? What can D(D) do? If D(D) halts, then D(D) runs forever. If D(D) runs forever, then D(D) halts. CONTRADICTION: program P must not exist.

Main points about computability Some functions are computable, some are not Halting problem Programming language implementation Can report error if program result is undefined due to division by zero, other undefined basic operation Cannot report error if program will not terminate

Syntax and Semantics of Programs

Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language implementation Syntax Semantics Transform program syntax into machine instructions that can be executed to cause the correct sequence of actions to occur

Interpreter vs Compiler Source Program Input Interpreter Output Source Program Compiler Input Target Program Output

Typical Compiler Source Program Lexical Analyzer Syntax Analyzer Semantic Analyzer Intermediate Code Generator Code Optimizer Code Generator Target Program See summary in course text, compiler books

Brief look at syntax Grammar e ::= n e+e e e n ::= d nd d ::= 0 1 2 3 4 5 6 7 8 9 Expressions in language e e e e e+e n n+n nd d+d dd d+d 27 4 + 3 Grammar defines a language Expressions in language derived by sequence of productions

Parse tree Derivation represented by tree e e e e e+e n n+n nd d+d dd d+d 27 4 + 3 e e e 27 e + e 4 3 Tree shows parenthesization of expression

Parsing Given expression find tree Ambiguity Expression 27 4 + 3 can be parsed two ways Problem: 27 (4 + 3) (27 4) + 3 Ways to resolve ambiguity Precedence Group * before + Parse 3*4 + 2 as (3*4) + 2 Associativity Parenthesize operators of equal precedence to left (or right) Parse 3 4 + 5 as (3 4) + 5 See book for more info

Chapter assignment Lisp (25.10) Foundations (1.11) ML/Algol language summary (8.11) Types and type inference (15.11) Scope, functions and storage management (22.11) Control in sequential languages (29.11) Modularity and Object-oriented languages (6.12 x 2) Simula and Smalltalk (13.12) C++ (20.12) Java (27.12 x 2) Concurrent and distributed programming (3.1 x 2) TBD (10.1)