Programming language design and analysis

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

CS 415 Midterm Exam Spring 2002

Programming Languages 2nd edition Tucker and Noonan"

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

Paradigms of computer programming

JVM ByteCode Interpreter

Topics Covered Thus Far CMSC 330: Organization of Programming Languages

Concepts of Programming Languages

Functional Programming in Java. CSE 219 Department of Computer Science, Stony Brook University

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

COSE212: Programming Languages. Lecture 0 Course Overview

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

Informal Semantics of Data. semantic specification names (identifiers) attributes binding declarations scope rules visibility

CMSC 330: Organization of Programming Languages

Functional Programming. Big Picture. Design of Programming Languages

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

Side Effects (3A) Young Won Lim 1/13/18

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

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

CSE341: Programming Languages Lecture 9 Function-Closure Idioms. Dan Grossman Winter 2013

CSCI-GA Scripting Languages

CS 242. Fundamentals. Reading: See last slide

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

Weeks 6&7: Procedures and Parameter Passing

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009

IA010: Principles of Programming Languages

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

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

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors.

Seminar in Programming Languages

CS 11 Haskell track: lecture 1

Concepts of Programming Languages

Functional Programming

Carlos Varela RPI September 19, Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL

Programming Language Concepts, cs2104 Lecture 01 ( )

General Overview of Mozart/Oz

Com S 541. Programming Languages I

CMSC 330: Organization of Programming Languages. Operational Semantics

Functional Programming and Haskell

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

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

CSE 505: Concepts of Programming Languages

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

Compilers Project Proposals

Programming with Math and Logic

Functional Programming Lecture 1: Introduction

More Lambda Calculus and Intro to Type Systems

Languages and Compilers

Programming Languages

Next: What s in a name? Programming Languages. Data model in functional PL. What s in a name? CSE 130 : Fall Lecture 13: What s in a Name?

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University

INF 102 CONCEPTS OF PROG. LANGS FUNCTIONAL COMPOSITION. Instructors: James Jones Copyright Instructors.

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

Submitted to the Onward track of OOPSLA-03 ABSTRACT. Keywords

Advanced Topics in Programming Languages Lecture 2 - Introduction to Haskell

Lecture 1: Introduction. 23. August, 2010

Multi-Paradigm Approach for Teaching Programming

Stop coding Pascal. Saturday, April 6, 13

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

Simply-Typed Lambda Calculus

CS 314 Principles of Programming Languages

CIS24 Project #3. Student Name: Chun Chung Cheung Course Section: SA Date: 4/28/2003 Professor: Kopec. Subject: Functional Programming Language (ML)

Lecture 8: Summary of Haskell course + Type Level Programming

Variables and Bindings

Programming Languages Third Edition. Chapter 7 Basic Semantics

(Refer Slide Time: 4:00)

Tracking the Flow of Ideas through the Programming Languages Literature

proc {Produce State Out} local State2 Out2 in State2 = State + 1 Out = State Out2 {Produce State2 Out2}

Declarative concurrency. March 3, 2014

Introduction to OCaml

SD314 Outils pour le Big Data

Haskell Monads CSC 131. Kim Bruce

Grad PL vs. The World

Chapter 11 :: Functional Languages

Chapter 5 Names, Binding, Type Checking and Scopes

Programming with Patterns. ACM SIGPLAN Developer Tracks on Functional Programming (DEFUN 2009)

CS457/557 Functional Languages

Scope, Functions, and Storage Management

Declarative Programming Techniques

cmpt 440/821 Advanced Topics in Programming Languages

Type Inference. Prof. Clarkson Fall Today s music: Cool, Calm, and Collected by The Rolling Stones

Programming Languages, Summary CSC419; Odelia Schwartz

Introduction to Functional Programming and Haskell. Aden Seaman

Overview. Distributed Computing with Oz/Mozart (VRH 11) Mozart research at a glance. Basic principles. Language design.

Principles of Compiler Construction ( )

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

Introduction to Concepts in Functional Programming. CS16: Introduction to Data Structures & Algorithms Spring 2017

Programming Language Pragmatics

Discussion Summaries and Recommendations

Programming Languages

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

Types in Programming Languages Dynamic and Static Typing, Type Inference (CTM 2.8.3, EPL* 4) Abstract Data Types (CTM 3.7) Monads (GIH** 9)

Every language has its own scoping rules. For example, what is the scope of variable j in this Java program?

Functional Programming Language Haskell

Concepts, Techniques, and Models of Computer Programming

Smalltalk: developed at Xerox Palo Alto Research Center by the Learning Research Group in the 1970 s (Smalltalk-72, Smalltalk-76, Smalltalk-80)

Module 10: Imperative Programming, Modularization, and The Future

The Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England

A Concepts-Based Approach for Teaching Programming

Transcription:

Programming language design and analysis Introduction Marius Minea 25 September 2017

Why this course? Programming languages are fundamental and one of the oldest CS fields Language design is an important current issue mainstream languages still appear and evolve (Java, C#,...) + lots of domain-specific languages Language design impacts software design (polymorphism, reflection,...), security (type safety, interference), efficiency (compilation...), etc. Analysis: needed in verification, testing, parallelization, certification, performance estimation,...

Course goals SIGPLAN motto: To explore programming language concepts and tools focusing on design, implementation and efficient use. Know the landscape of programming languages Understand language features and impact of design decisions Learn language/program analysis techniques (semantics, reasoning) Introduction to current programming language research

Words of wisdom a programming language is a tool which should assist the programmer in the most difficult aspects of his art, namely program design, documentation, and debugging [Hoare, Hints on programming language design, 1973]

Research ideas Main programming language conferences (ACM SIGPLAN) PoPL: Principles of Programming Languages PLDI: Programming Language Design and Implementation OOPSLA: Object-Oriented Programming, Languages, Systems and Applications (now: SPLASH) All of them have most influential paper award (10 years later) + best paper award (current year) + 20 years of PLDI (1979-1999)

Other potential topics [please express interest] symbolic computation lazy evaluation, closures, higher-order functions and continuations, concurrency, inter-process communication and synchronization, active objects and mobile agents, object views, directed interfaces, and dynamic type systems, reflection and introspection persistent object systems and garbage collection, error management, assertions and declarative debugging, aspect-oriented programming, generative programming, constraint imperative programming, staged compilation and virtual machines course, Linköping University

For a start: small is beautiful Functional programming simple mathematical foundation: lambda calculus (possibly typed) in pure form avoids state and mutable data The determined Real Programmer can write functional programs in any language Exercise 1: program without state and variables in C (paraphrasing Ed Post) Exercise 2: simulate state and an interpreter in Haskell / ML (lab)

What is programming? Programming encompasses three things: 1. a computation model: a formal system that defines a language and how it is executed on an abstract machine 2. a set of programming techniques and design principles used to write programs in that language 3. a set of reasoning techniques for reasoning about programs and calculating their efficiency [vanroy & Haridi, Concepts, Techniques and Models of Computer Programming]

Paradigms and concepts programming paradigm = approach to programming based on a mathematical theory or a coherent set of principles many languages fewer paradigms still fewer concepts Key concepts form a paradigm s core (kernel) language

Functional paradigm Evaluate an expression and use the value for something Discipline and idea: Mathematics and the theory of functions Values produced are non-mutable Impossible to change part of a composite value But can make a revised copy of composite value Atemporal: no matter when done, computation produces same value pure functional programming is side-effect free Applicative: all computations done by applying (calling) functions Functions are the natural abstraction (for expression evaluation) Functions are first-class values: full-fledged data just like numbers, lists,... Computations driven by needs after K. Normark, course, Aalborg U.

First-class objects A first-class object is one that can be: passed as an argument returned as a value, and stored in a data structure. What is first-class influences your choices of abstraction: Languages with first-class functions can represent data as procedures. Example: represent environment two constructors: empty environment enlarge environment with (symbol, value) pair one observer: give value of symbol in environment

Advantages of simplicity Functional / declarative operations are: independent (do not depend on any external execution state) stateless (no internal execution state remembered between calls) deterministic (same result when given same arguments) Why is functional programming important? Declarative programs are compositional naturally concurrent (since stateless) Reasoning about declarative programs is simple [van Roy & Haridi]

Learn by interpreting This book brings you face-to-face with the most fundamental idea in computer programming: The interpreter for a computer language is just another program Hal Abelson foreword to Friedman, Wand & Haynes, Essentials of Programming Languages Writing an interpreter: makes you think about fundamental concepts defines the meaning of programs: semantics our first lab assignment

Key concepts: Binding binding a name/identifier to an object (expression/value) static: before running the program (e.g., usual function call) dynamic: at runtime (e.g., OO virtual method call) Binding and variable assignment are NOT the same. Pure functional languages have binding but do NOT have assignment (mutable values) Rebinding and mutation are NOT the same.

Scope = a context to which objects (names, etc.) are associated an identifier is visible within its scope lexical (static) scoping determined by program text, not by runtime execution sequence aids modularity, understanding, reasoning (in isolation) dynamic scoping scope=remainder of the execution during which binding is in effect each identifier has stack of bindings (push/pop on enter/exit scope) meaning of code depends on past execution (of other code) Some languages allow choice of static / dynamic scoping (e.g., Perl)

First-class functions Functions can be: passed as an argument returned as a value, and stored in a data structure. Ex. List.map (fun x -> x + 1) [1;2;3] Data.List.map (\x -> x + 1) [1,2,3] (ML) (Haskell)

Higher-order functions = functions that return a function e.g., (+): int -> int -> int = <fun> (ML) (+) 3: int -> int = <fun> (same as fun x -> x + 3) A function of several parameters can be rewritten through currying (after Haskell Curry) fun x y -> x + y fun x -> fun y -> x + y

Closures = a function together with an environment defining its free variables needed to implement static scoping with first-order functions Python example [cf. Wikipedia] def counter(): x = 0 def inc(): nonlocal x x += 1 print(x) return inc counter1_inc = counter() counter2_inc = counter() counter1_inc() # 1 counter1_inc() # 2 counter2_inc() # 1 counter1_inc() # 3