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

Similar documents
Programming Languages

Concepts of Programming Languages

Com S 541. Programming Languages I

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

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

Grade Weights. Language Design and Overview of COOL. CS143 Lecture 2. Programming Language Economics 101. Lecture Outline

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

Programming Languages 2nd edition Tucker and Noonan"

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

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

Programming Languages, Summary CSC419; Odelia Schwartz

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

Course outline. CSE 341: Programming Languages. Why study programming languages? Course motivation and objectives. 1 lecture: Concepts

Programmiersprachen (Programming Languages)

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

COSE212: Programming Languages. Lecture 0 Course Overview

Simply-Typed Lambda Calculus

! Broaden your language horizons. ! Study how languages are implemented. ! Study how languages are described / specified

1DL321: Kompilatorteknik I (Compiler Design 1) Introduction to Programming Language Design and to Compilation

1DL321: Kompilatorteknik I (Compiler Design 1) Introduction to Programming Language Design and to Compilation

Today s Class. Programming Languages Topic of Ultimate Mastery. Reasonable Initial Skepticism. Meta-Level Information

1DL321: Kompilatorteknik I (Compiler Design 1)

Concepts in Programming Languages

CS558 Programming Languages

Principles of Programming Languages. Lecture Outline

CSCI 3136 Principles of Programming Languages

Type Checking and Type Inference

Scope and Introduction to Functional Languages. Review and Finish Scoping. Announcements. Assignment 3 due Thu at 11:55pm. Website has SML resources

CS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013

CS 314 Principles of Programming Languages

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

INF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes

Concepts of Programming Languages

Type Systems. Today. 1. Organizational Matters. 1. Organizational Matters. Lecture 1 Oct. 20th, 2004 Sebastian Maneth. 1. Organizational Matters

Chapter 1. Preliminaries

Programming Languages Lecture 15: Recursive Types & Subtyping

CS 242. Fundamentals. Reading: See last slide

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

Operational Semantics. One-Slide Summary. Lecture Outline

NOTE: Answer ANY FOUR of the following 6 sections:

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

Compiler Design 1. Introduction to Programming Language Design and to Compilation

Chapter 1. Preliminaries

CIS 500 Software Foundations Fall December 6

Administrivia. Existential Types. CIS 500 Software Foundations Fall December 6. Administrivia. Motivation. Motivation

Programming language design and analysis

INF 212 ANALYSIS OF PROG. LANGS Type Systems. Instructors: Crista Lopes Copyright Instructors.

More Lambda Calculus and Intro to Type Systems

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

(Advanced) topics in Programming Languages

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

Mutable References. Chapter 1

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

Introduction. A. Bellaachia Page: 1

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

CSE341: Programming Languages Lecture 11 Type Inference. Dan Grossman Spring 2016

Formal Systems and their Applications

Lecture #23: Conversion and Type Inference

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

Conversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = "Hello";

Introduction to Programming Languages and Compilers. CS164 11:00-12:30 TT 10 Evans. UPRM ICOM 4029 (Adapted from: Prof. Necula UCB CS 164)

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

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

CS558 Programming Languages

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

Chapter 1 Preliminaries

Types. What is a type?

Subtyping. Lecture 13 CS 565 3/27/06

MIDTERM EXAMINATION - CS130 - Spring 2005

Why study Programming Language Concepts? Chapter One. Language Evaluation Criteria. Programming Domains. Readability Writability Reliability Cost

Programming Language Concepts 1982, 1987, Outline. Period

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

IA010: Principles of Programming Languages

CMSC 330: Organization of Programming Languages

CS6202: Advanced Topics in Programming Languages and Systems Lecture 0 : Overview

Harvard School of Engineering and Applied Sciences Computer Science 152

CSc 372 Comparative Programming Languages

COS 320. Compiling Techniques

Lecture 1: Course Introduction

Types, Type Inference and Unification

CS 415 Midterm Exam Spring 2002

Recursive Types and Subtyping

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Introduction. COMP 524: Programming Language Concepts Björn B. Brandenburg. The University of North Carolina at Chapel Hill

Seminar in Programming Languages

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

Topics Covered Thus Far CMSC 330: Organization of Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

CPS 506 Comparative Programming Languages. Programming Language Paradigm

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

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Part VI. Imperative Functional Programming

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE

What is a programming language?

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far

Recursive Types and Subtyping

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08

MPRI course 2-4 Functional programming languages Exercises

Transcription:

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

Administrivia Who am I? Course web page http://www.cs.purdue.edu/homes/peugster/cs565spring08/ Office hours By appointment Main text Types and Programming Languages, B. Pierce, MIT Press

Course Work Lectures Homeworks Periodic (probably one every three weeks or so) The answers to questions will be available in the back of the text Collaborating on homework encouraged Programming exercises Will involve implementing type checkers and interpreters Code size for solutions will be small (< 250 lines), but solutions will be challenging A midterm Cumulative final which will also serve as the qualifying exam

Prerequistes Programming experience/maturity Exposure to various language constructs Java, ML, Lisp, Prolog, C Undergraduate compilers and/or PL class CS 352 and/or CS456 or equivalent Mathematical maturity Familiarity with first-order logic, set theory, graph theory, induction Most important Intellectual curiosity and creativity

Resources Web page for text http://www.cis.upenn.edu/~bcpierce/tapl Supplementary material/page for ML implementations http://www2.imm.dtu.dk/~riis/ppa/ppasup2004.html http://caml.inria.fr (Caml) http://www.smlnj.org (SML/NJ) http://www.mlton.org (MLton) Proceedings of conferences POPL, PLDI, ICFP,...

Background Our main goal is to find ways to describe the behavior of programs precisely and concisely Motivation Significant industry and government interest Web, Java Security issues Complexity of modern-day applications

Motivation (cont) Prove specific facts about programs Verify correctness Important in mission-critical systems Safety or isolation properties Need an unambiguous vocabulary Understand specific language features Better language design Guide improvements in implementations

Goals A more sophisticated appreciation of programs, their structure, and the field as a whole Viewing programs as rich, formal, mathematical objects, not mere syntax Define and prove rigorous claims about a program s meaning and behavior Develop sound intuitions to better judge language properties Develop tools to be better programmers, designers and computer scientists

Non-goals An introduction to advanced programming techniques No detailed discussion of machine implementations The course will not be motivated from the perspective of a compiler writer But, impact of design decisions on implementation tractability will be considered when appropriate A survey of different languages

Topics Part I (Foundations): Semantic formalisms, λ- calculus, abstract interpretation, introduction to types Part II (Design): Simply-typed λ-calculus, records, references, subtyping, object-based programming Part III (Features): Polymorphism, abstract data types, advanced topics (e.g., concurrency, linearity,...)

Semantics Three classical approaches Operational Define programs in terms of rules that apply to a specific virtual machine Useful for implementing a compiler or interpreter Denotational Meaning in terms of functions from syntax (program text) to domains (values) Useful for describing the behavior of programs Axiomatic Logical rules for reasoning about programs Useful for proving program correctness

Abstract Interpretation Reason about programs by abstracting away properties that are not of interest Type systems Sign arithmetic Reason about the correspondence between results produced in the abstract world with results that would be produced in the concrete world 12

Language Design Designed to fill a void Enable expression of previously difficult-to-express applications Main overhead Programmer training Languages with many users rarely get replaced (Cobol) Ossification Easy to start in a new niche

Language Design Tower of Babel Applications often have distinct (and conflicting) needs AI (Lisp, Prolog, Scheme) Scientific computing (Fortran) Business (Cobol) Systems programming (C) Scripting (Perl, Javascript) Distributed computation (Java) Special-purpose (...) Important to understand differences and similarities among different language features

Paradigms Imperative Fortran, Algol, C, Pascal Designed around a notion of a program store Program behavior expressed in terms of transformations on the store Functional Lisp, ML, Scheme, Haskell Programs described in terms of a collection of functions Pure functional languages are state-free Logic Prolog Programs described in terms of a collection of logical relations Concurrent Fortran90, CSP, Linda Special purpose TeX, Postscript, HTML

Metrics No universally accepted criteria The most popular languages are not necessarily the best ones Consider Cobol or JCL (Job Control Language) Although, aren t notions of superiority highly subjective? General characteristics Simplicity and elegance (orthogonality) Readability Safety Programming-in-the-large Efficiency Abstraction

Case studies Lisp 1.5 Based on λ-calculus Key aspect of the calculus is notion of substitution of free variables: function f (args) =... x... Suppose x is not included in args. Where should the binding for x be constructed? At the point where f is defined (lexical scoping) At the points where f is applied (dynamic scoping) Lisp 1.5 (and later dialects) chose dynamic scoping, even though it is widely agreed today that lexical scoping is the more sensible choice. When do these distinctions arise? Why are the differences important? Lack of formal semantics to explore the ramifications of design choice

Case studies ML Interaction of types with references Polymorphism: code that works uniformly on all various types of data length: α list -> int hd: α list -> α tl: α list -> α list Type inference Assign the most general type to variables based on the contexts in which they occur

Case studies: ML References Like updateable pointers in C Expressions ref e: τ -> τ ref!e: τ ref -> τ e 1 := e 2 : τ ref * τ -> τ ref fun id(x) = x id: α -> α val c = ref id c: (α -> α) ref fun inc(x) = x + 1 inc: int -> int c := inc Ok if we infer c: (int -> int) ref!c (true) Ok if we infer c: (bool -> bool) ref

Case studies Eiffel Strongly-typed object-oriented language that supports inheritance Uses a notion of covariance (rather than contravariance) in typing functions A function with a restricted set of inputs can be used in a context where a function with a wider set of arguments is expected Type system may fail to prevent runtime type errors Failure to cleanly separate notions of subtyping from subclassing

Lessons Language design is as much about safety as it is about efficiency and expressiveness. Need tools and frameworks to reason about and compare different language features and designs: untyped λ-calculus as a universal computation language. Precisely define its behavior using different semantic models (operational, denotational, axiomatic) typed λ-calculi to express safety and abstraction properties.

Homework Reading: Chapter 1 Familiarize yourself with ML Next time: Mathematical preliminaries Introduction to untyped arithmetic