The gradual typing approach to mixing static and dynamic typing

Size: px
Start display at page:

Download "The gradual typing approach to mixing static and dynamic typing"

Transcription

1 1/38 The gradual typing approach to mixing static and dynamic typing Jeremy G. Siek University of Colorado =) Indiana University TFP 2013 at Provo, Utah, May 2013

2 The Goals of Gradual Typing I Enjoy the benefits of static & dynamic typing in different parts of the same program. I Provide seamless interoperability between the static & dynamic parts. Static Typing Reliability & Efficiency Dynamic Typing Productivity 2/38

3 Overview Gradual Typing: I Basics I History I Functions I Objects I Generics I Mutable State I The Future 3/38

4 How can Static and Dynamic Coexist? 1 def abs(n: int) int: return -n if n<0 else n def dist(x, y): return abs(x - y) 1 Gradual Typing for Functional Languages, Siek and Taha, SFP /38

5 How can Static and Dynamic Coexist? 2 Consistency: def abs(n: int) int: return -n if n<0 else n T? int int? T str str def dist(x :?, y :?)?: return abs(x - y)? int T 1 T 3 T 2 T 4 T 1! T 2 T 3! T 4 Type rule for application: ` e 1 : T 1! T 3 ` e 2 : T 2 T 1 T 2 ` e 1 e 2 : T 3 2 Gradual Typing for Functional Languages, Siek and Taha, SFP /38

6 6/38 Properly Catch Static Errors def abs(n: int) int: return -n if n<0 else n x : str = input_string()... abs(x) str 6 int Consistency: T? int int? T str str T 1 T 3 T 2 T 4 T 1! T 2 T 3! T 4

7 Compiler Performs Cast Insertion def abs(n: int) int: return -n if n<0 else n def dist(x :?, y :?)?: return abs(x - y :? ) int) : int )? dist(7 : int )?, 3 : int )?) The dynamic semantics specifies the behavior of casts, e.g., (7 : int )?) :? ) int! 7 (7 : int )?) :? ) str! error 7/38

8 Overview Gradual Typing: I Basics I History I Functions I Objects I Generics I Mutable State I The Future 8/38

9 The Prehistory of Gradual Typing Lisp, early 1980 s types as optimization hints Abadi et al., 1991 defined a dynamic type with explicit injection and projection terms. Cartwright & Fagan, 1991 soft typing: static analysis of dynamic programs Henglein, 1992 expressed dynamic casts using an algebra of coercions. Thatte, 1994 introduced implicit casts based on subtyping, which didn t quite work. Findler & Felleisen, 2002 designed contracts for higher-order functions. 9/38

10 History of Gradual Typing (Abbreviated) *Siek & Taha, 2006 implicit casts, consistency Herman et al., 2006 space-efficient casts *Siek & Taha, 2007 gradual typing & objects Adobe, 2006 ActionScript becomes gradual Sam TH & Felleisen, 2008 Typed Scheme Wadler & Findler, 2009 the Blame Theorem *Garcia et. al, 2009 space-efficient blame Larry Wall, 2009 Perl 6 becomes gradual Bierman et al, 2010 C# becomes gradual *Ahmed, et al., 2011 gradual typing & generics Hejlsberg, 2012 Microsoft releases TypeScript *Siek et al., 2012 gradual typing & mutable state 10 / 38

11 Overview Gradual Typing: I Basics I History I Functions I Objects I Generics I Mutable State I The Future 11 / 38

12 12 / 38 Higher-Order Functions are Hard def deriv(d: float, f: float!float) float: return lambda(x:float): (f(x+d)-f(x-d)) / (2.0*d) 1 def g(y): 2 if y > 0: 3 return y**3 - y else: 5 return "yikes" 6 7 deriv(0.01, g)(3.0) 8 deriv(0.01, g)(-3.0)

13 Higher-Order Functions and Blame def deriv(d: float, f: float!float) float: return lambda(x:float): (f(x+d)-f(x-d)) / (2.0*d) 1 def g(y): 2 if y > 0: 3 return y**3 - y else: 5 return "yikes" 6 7 deriv(0.01, g)(3.0) 8 deriv(0.01, g)(-3.0) Casting a function creates a wrapper : g :?!? ) 8 float! float p : float.! g (p : float ) 8?) :? ) 8 float yikes :str )? ) 8 float! blame 8 13 / 38

14 14 / 38 Is Gradual Typing Unsound? 3 4 adding type annotations at random places is unsound Matthias Felleisen, PLT Mailing List, June 10, 2008.

15 14 / 38 Is Gradual Typing Unsound? 3 4 adding type annotations at random places is unsound Matthias Felleisen, PLT Mailing List, June 10, Too weak: If ` e : T, then either e diverges, e e! error.! v and ` v : T, or

16 14 / 38 Is Gradual Typing Unsound? 3 4 adding type annotations at random places is unsound Matthias Felleisen, PLT Mailing List, June 10, Too weak: If ` e : T, then either e diverges, e e! error.! v and ` v : T, or Too strong: If ` e : T, then either e diverges or e! v and ` v : T.

17 Is Gradual Typing Unsound? 3 4 adding type annotations at random places is unsound Matthias Felleisen, PLT Mailing List, June 10, Too weak: If ` e : T, then either e diverges, e e! error.! v and ` v : T, or Too strong: If ` e : T, then either e diverges or e! v and ` v : T. Just right: If ` e : T, then either e diverges, e! v and ` v : T, or e! blame ` where e = C[e 0 : T 1 )` T 2 ] and T 1 6<: T 2. 3 Well-typed Program s Can t be Blamed, Wadler & Findler, ESOP Exploring the Design Space of H.O. Casts, Siek et al., ESOP / 38

18 15 / 38 Blame and Subtyping Wadler & Finder, 2009: int <: int?<:? int <:? T <:??! T <:? T 3 <: T 1 T 2 <: T 4 T 1!T 2 <: T 3!T 4 Siek, Garcia, & Taha, 2009: int <: int T <:? T 3 <: T 1 T 2 <: T 4 T 1!T 2 <: T 3!T 4

19 But Wrappers are Not Space Efficient 5 def even(n: int, k:?! Bool) Bool: if n == 0: return k(true) else: return odd(n - 1, k) def odd(n: int, k: Bool!Bool) Bool: if n == 0: return k(false) else: return even(n - 1, k) 5 Space-Efficient Gradual Typing. Herman, et al., TFP / 38

20 17 / 38 Toward Efficient Casts: Reified Wrappers Regular wrappers: v ::=... x : T. e v : T 1!T 2 ) T 3!T 4! x : T 3. (v (x : T 3 ) T 1 )) : T 2 ) T 4 Reified wrappers: + v ::=... x : T. e v : T 1!T 2 ) T 3!T 4 (v 1 : T 1!T 2 ) T 3!T 4 ) v 2! (v 1 (v 2 : T 3 ) T 1 )) : T 2 ) T 4

21 Compressing a Sequence of Casts 6 v :?!? )?! str!? ) int!?!? )?!?! int v :?!? ) int! str! int )?!?! int Define an information ordering:? v T int v int str v str T 1 v T 3 T 2 v T 4 T 1! T 2 v T 3! T 4 Take the least upper bound to obtain a triple : e : T 1 ) T 2 ) )T n 1 ) T n e : T 1 )t{t 2,...,T n 1 })T n 6 Threesomes, with and without blame. Siek & Wadler, POPL / 38

22 19 / 38 Space Efficiency Notation: e erases the casts from e. Theorem (Space Efficiency) For any program e there is a constant factor c such that if e 7! e 0, then size(e 0 ) apple c size( e 0 ).

23 Overview Gradual Typing: I Basics I History I Functions I Objects I Generics I Mutable State I The Future 20 / 38

24 21 / 38 Gradual Typing and Subtyping At the heart of most OO languages is a subsumption rule: ` e : T 1 T 1 <: T 2 ` e : T 2 Thatte s early attempt at gradual typing didn t use consistency but instead put the dynamic type at the top and bottom of the subtyping relation. T <:?? <: T

25 22 / 38 The Problem with Subtyping Subtyping is transitive, so we have: str <:?? <: int str <: int In general, for any types T 1 and T 2 we have T 1 <: T 2. So the type checker accepts all programs! (Even ones that get stuck.)

26 Consistency and Subtyping are Orthogonal 7 Let subtyping deal with object types: [l i : T i i21..n+m ] <: [l i : T i i21..n ]?<:? Let consistency deal with the dynamic type: T? Include the subsumption rule? T ` e : T 1 T 1 <: T 2 ` e : T 2 and use consistency instead of equality: ` e 1 : T 1! T 3 ` e 2 : T 2 T 1 T 2 ` e 1 e 2 : T 3 7 Gradual Typing for Objects, Siek and Taha, ECOOP / 38

27 24 / 38 An Algorithmic Type System The usual trick is to remove the subsumption rule and use subtyping in place of equality. ` e 1 : T 1! T 3 ` e 2 : T 2 T 2 <: T 1 ` e 1 e 2 : T 3 but for gradual typing, this would look like ` e 1 : T 1! T 3 ` e 2 : T 2 T 2 <: T1 0 T1 0 T 1 ` e 1 e 2 : T 3 which is not syntax directed. We need a relation that composes the two: ` e 1 : T 1! T 3 ` e 2 : T 2 T 2. T 1 ` e 1 e 2 : T 3

28 25 / 38 Consistent-Subtyping T.??. T int. int str. str T 3. T 1 T 2. T 4 T i. Ti 0 8i 2 1..n T 1! T 2. T 3! T 4 [l i : T i21..n+m i ]. [l i : T 0 (This is a more direct definition than the one I gave in Gradual Typing for Objects.) i i21..n ]

29 Overview Gradual Typing: I Basics I History I Functions I Objects I Generics I Mutable State I The Future 26 / 38

30 27 / 38 Gradual Typing & Polymorphism Review of System F: T ::=... 8X. T e ::=... X. e e[t ] ( X. e)[t ]! e[x:=t ], X ` e : T ` X. e : 8X. T ` e : 8X. T 1 ` e[t 2 ]:T 1 [X:=T 2 ]

31 Parametric Polymorphism (Generics) Ahmed, Findler, and Wadler proposed a design at STOP Their goals: I Seamless interoperability. v :(8X. S) ) T! v[?] :S[X:=?] ) T v : S ) (8X. T )! X. (v : S ) T ) I Retain relational parametricity (i.e., theorems for free). I Provide a natural subtyping relation and blame theorem. I helped refine the design for the POPL 2011 paper. 28 / 38

32 Challenges to Parametricity Consider two casts: K? =( x:?. y:?.x) :?!?!? )? K? :? ) m 8X.8Y. X! Y! X K? :? )` 8X.8Y. X! Y! Y The second cast should lead to a cast failure. But a naive semantics lets it go through. (K? :? )` 8X.8Y. X! Y! Y )[int][int] 23! (K? :? )` int! int! int) 23! 2 : int )? )` int! 2 29 / 38

33 Enforcement of Parametricity (K? :? )` 8X.8Y. X! Y! X)[int][int] 23! ( X:=int. Y :=int. K? :? )` X! Y! X) 23! ( X:=int. Y :=int. 2 : X )? )` X)! 2 (K? :? )` 8X.8Y. X! Y! Y )[int][int] 23! ( X:=int. Y :=int. K? :? )` X! Y! Y ) 23! ( X:=int. Y :=int. 2 : X )? )` Y )! blame ` This mechanism should work, but the parametricity theorem is an open problem. 30 / 38

34 Overview Gradual Typing: I Basics I History I Functions I Objects I Generics I Mutable State I The Future 31 / 38

35 32 / 38 Gradual Typing & Mutable State Consider ML-style references T ::=... ref T e ::=... ref e e := e!e with a permissive rule for consistency of reference types: T 1 T 2 ref T 1 ref T 2

36 33 / 38 The Standard Semantics Incurs Overhead The Herman TFP 2006 semantics induces overhead, even in statically-typed regions of code. a 2 N v ::=... a v : ref T 1 ) ref T 2 ref v µ 7! a µ(a := v) if a /2 dom(µ) ( µ(a) µ if v = a!v µ 7! (!v 0 ):T 1 ) T 2 µ if v = v 0 : ref T 1 ) ref T 2 ( v 2 µ(a := v 2 ) if v 1 = a v 1 := v 2 µ 7! v1 0 := (v 2:T 2 )T 1 ) µ if v 1 = v1 0 : ref T 1)ref T 2

37 % Monotonic References e ::=... ref e e := e!e e := e@t!e@t v ::=... a let r1 = ref (42 : int )?) in let r2 = r1 : ref? ) ref int in (!r1@?,!r2) ref? ref? +3ref int ( (42 : int )?,?) (42, int) 34 / 38

38 35 / 38 Standard vs. Monotonic 1 let r1 = ref (1 : int )?) in 2 let r2 = r1 : ref? ) ref int in 3 let r3 = r1 : ref? ) ref bool in 4 let x =!r2 in 5 r3 := true; 6 let y =!r3 in 7 (x,y) 7! (1, true) (standard) 7! blame 3 (monotonic)

39 e µ! e 0 Monotonic References ref T v µ! a a := (v, T ) if a /2 dom(µ)!a µ! µ(a) 1 a := v µ! a a := (v,µ(a) 2 ) a : ref T 1 ) ref T 2 µ! error if T 2 6 µ(a) 2 a : ref T 1 ) ref T 2 µ! a if T 2 v µ(a) 2 a : ref T 1 ) ref T 2 µ! a a := (e,µ(a) 2 t T 2 ) if T 2 6v µ(a) 2, e = µ(a) 1 : µ(a) 2 ) µ(a) 2 t T 2!a@T µ! (µ(a) 1 : µ(a) 2 ) T ) a := v@t µ! a a := (v : T ) µ(a) 2,µ(a) 2 ) e µ 7! e 0 µ 0 e µ! e 0 e µ 7! e 0 (µ) µ(a)=(e 1, T ) e 1 µ! e 0 1 e µ 7! e (µ(a := (e 0 1, T ))) 36 / 38

40 Overview Gradual Typing: I Basics I History I Functions I Objects I Generics I Mutable State I The Future 37 / 38

41 The Future I Gradually-typed Python (Michael Vitousek) I Monotonic references with blame (some ideas, not easy) I Monotonic objects (draft) I Putting it all together, e.g. can we maintain space efficiency with polymorphic blame? (no idea) I Parametricity for the Polymorphic Blame Calculus (Amal Ahmed is part way there) I Compiling and optimizing gradually-typed programs (e.g. Rastogi, Chaudhuri, and Hosmer, POPL 2012) Questions? 38 / 38

Well-typed programs can t be blamed

Well-typed programs can t be blamed Well-typed programs can t be blamed Philip Wadler University of Edinburgh Robert Bruce Findler University of Chicago Abstract We introduce the blame calculus, which adds the notion of blame from Findler

More information

Typed Lua: An Optional Type System for Lua

Typed Lua: An Optional Type System for Lua Typed Lua: An Optional Type System for Lua André Murbach Maidl PUC-Rio Rio de Janeiro, Brazil amaidl@inf.puc-rio.br Fabio Mascarenhas UFRJ Rio de Janeiro, Brazil mascarenhas@ufrj.br Roberto Ierusalimschy

More information

Language with a Pluggable Type System and Optional Runtime Monitoring of Type Errors

Language with a Pluggable Type System and Optional Runtime Monitoring of Type Errors Language with a Pluggable Type System and Optional Runtime Monitoring of Type Errors Jukka Lehtosalo and David J. Greaves University of Cambridge Computer Laboratory firstname.lastname@cl.cam.ac.uk Abstract.

More information

Blame for All. Jeremy G. Siek. Amal Ahmed. Robert Bruce Findler. Philip Wadler. Abstract. 1. Introduction

Blame for All. Jeremy G. Siek. Amal Ahmed. Robert Bruce Findler. Philip Wadler. Abstract. 1. Introduction Blame for All Amal Ahmed Indiana University amal@cs.indiana.edu Robert Bruce Findler Northwestern University robby@eecs.northwestern.edu Jeremy G. Siek University of Colorado at Boulder jeremy.siek@colorado.edu

More information

Integrating Typed and Untyped Code in a Scripting Language

Integrating Typed and Untyped Code in a Scripting Language Integrating Typed and Untyped Code in a Scripting Language Tobias Wrigstad Francesco Zappa Nardelli Sylvain Lebresne Johan Östlund Jan Vitek PURDUE UNIVERSITY INRIA Abstract Many large software systems

More information

A Type System for Data-Flow Integrity on Windows Vista

A Type System for Data-Flow Integrity on Windows Vista A Type System for Data-Flow Integrity on Windows Vista Avik Chaudhuri University of California at Santa Cruz avik@cs.ucsc.edu Prasad Naldurg Sriram Rajamani Microsoft Research India {prasadn,sriram}@microsoft.com

More information

Analyse et Conception Formelle. Lesson 5. Crash Course on Scala

Analyse et Conception Formelle. Lesson 5. Crash Course on Scala Analyse et Conception Formelle Lesson 5 Crash Course on Scala T. Genet (ISTIC/IRISA) ACF-5 1 / 36 Bibliography Simply Scala. Online tutorial: http://www.simply.com/fr http://www.simply.com/ Programming

More information

Type Classes with Functional Dependencies

Type Classes with Functional Dependencies Appears in Proceedings of the 9th European Symposium on Programming, ESOP 2000, Berlin, Germany, March 2000, Springer-Verlag LNCS 1782. Type Classes with Functional Dependencies Mark P. Jones Department

More information

Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!

Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014! Programming Language Rankings Lecture 15: Type Inference, polymorphism & Type Classes CSC 131 Fall, 2014 Kim Bruce Top Combined Tiobe Index 1. JavaScript (+1) 2. Java (-1) 3. PHP 4. C# (+2) 5. Python (-1)

More information

Hybrid Type Checking

Hybrid Type Checking Hybrid Type Checking Cormac Flanagan Department of Computer Science University of California, Santa Cruz cormac@cs.ucsc.edu Abstract Traditional static type systems are very effective for verifying basic

More information

Sage: Unified Hybrid Checking for First-Class Types, General Refinement Types, and Dynamic (Extended Report)

Sage: Unified Hybrid Checking for First-Class Types, General Refinement Types, and Dynamic (Extended Report) Sage: Unified Hybrid Checking for First-Class Types, General Refinement Types, and Dynamic (Extended Report) Kenneth Knowles Aaron Tomb Jessica Gronski Stephen N. Freund Cormac Flanagan University of California,

More information

Semester Review. CSC 301, Fall 2015

Semester Review. CSC 301, Fall 2015 Semester Review CSC 301, Fall 2015 Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out:! Imperative Languages! assignment and iteration!

More information

Programming Languages

Programming Languages Programming Languages Qing Yi Course web site: www.cs.utsa.edu/~qingyi/cs3723 cs3723 1 A little about myself Qing Yi Ph.D. Rice University, USA. Assistant Professor, Department of Computer Science Office:

More information

Journal of Functional Programming, volume 3 number 4, 1993. Dynamics in ML

Journal of Functional Programming, volume 3 number 4, 1993. Dynamics in ML Journal of Functional Programming, volume 3 number 4, 1993. Dynamics in ML Xavier Leroy École Normale Supérieure Michel Mauny INRIA Rocquencourt Abstract Objects with dynamic types allow the integration

More information

A Generic Type-and-Effect System

A Generic Type-and-Effect System A Generic Type-and-Effect System Daniel Marino Todd Millstein Computer Science Department University of California, Los Angeles dlmarino,todd}@cs.ucla.edu Abstract Type-and-effect systems are a natural

More information

Functional Programming. Functional Programming Languages. Chapter 14. Introduction

Functional Programming. Functional Programming Languages. Chapter 14. Introduction Functional Programming Languages Chapter 14 Introduction Functional programming paradigm History Features and concepts Examples: Lisp ML 1 2 Functional Programming Functional Programming Languages The

More information

Overview. Elements of Programming Languages. Advanced constructs. Motivating inner class example

Overview. Elements of Programming Languages. Advanced constructs. Motivating inner class example Overview Elements of Programming Languages Lecture 12: Object-oriented functional programming James Cheney University of Edinburgh November 6, 2015 We ve now covered: basics of functional and imperative

More information

Python 2 and 3 compatibility testing via optional run-time type checking

Python 2 and 3 compatibility testing via optional run-time type checking Python 2 and 3 compatibility testing via optional run-time type checking Raoul-Gabriel Urma Work carried out during a Google internship & PhD https://github.com/google/pytypedecl Python 2 vs. Python 3

More information

The Ruby Type Checker

The Ruby Type Checker The Ruby Type Checker Brianna M. Ren John Toman T. Stephen Strickland Jeffrey S. Foster Department of Computer Science University of Maryland, College Park {bren, jtoman, sstrickl, jfoster}@cs.umd.edu

More information

Semantic Analysis: Types and Type Checking

Semantic Analysis: Types and Type Checking Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors

More information

The Needle Programming Language

The Needle Programming Language The Needle Programming Language The Needle Programming Language 1 What is Needle? Needle is an object-oriented functional programming language with a multimethod-based OO system, and a static type system

More information

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis

More information

Chapter 7: Functional Programming Languages

Chapter 7: Functional Programming Languages Chapter 7: Functional Programming Languages Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Fun: a language

More information

POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful

POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful RALF HINZE Institute of Information and Computing Sciences Utrecht University Email: ralf@cs.uu.nl Homepage: http://www.cs.uu.nl/~ralf/

More information

Lecture 18-19 Data Types and Types of a Language

Lecture 18-19 Data Types and Types of a Language Lecture 18-19 Data Types and Types of a Language April 29, 2014 Data Types and Types of a Language Data, Data Types and Types Type: Generalities Type Systems and Type Safety Type Equivalence, Coercion

More information

Programming Languages Featherweight Java David Walker

Programming Languages Featherweight Java David Walker Programming Languages Featherweight Java David Walker Overview Featherweight Java (FJ), a minimal Javalike language. Models inheritance and subtyping. Immutable objects: no mutation of fields. Trivialized

More information

How To Write A Type System

How To Write A Type System Type Systems 1 Introduction Luca Cardelli Digital Equipment Corporation Systems Research Center The fundamental purpose of a type system is to prevent the occurrence of execution errors during the running

More information

Chapter 15 Functional Programming Languages

Chapter 15 Functional Programming Languages Chapter 15 Functional Programming Languages Introduction - The design of the imperative languages is based directly on the von Neumann architecture Efficiency (at least at first) is the primary concern,

More information

CSE 307: Principles of Programming Languages

CSE 307: Principles of Programming Languages Course Organization Introduction CSE 307: Principles of Programming Languages Spring 2015 R. Sekar Course Organization Introduction 1 / 34 Topics 1. Course Organization Info and Support Course Description

More information

CMCS 312: Programming Languages Lecture 3: Lambda Calculus (Syntax, Substitution, Beta Reduction) Acar & Ahmed 17 January 2008

CMCS 312: Programming Languages Lecture 3: Lambda Calculus (Syntax, Substitution, Beta Reduction) Acar & Ahmed 17 January 2008 CMCS 312: Programming Languages Lecture 3: Lambda Calculus (Syntax, Substitution, Beta Reduction) Acar & Ahmed 17 January 2008 Contents 1 Announcements 1 2 Introduction 1 3 Abstract Syntax 1 4 Bound and

More information

Pretty-big-step semantics

Pretty-big-step semantics Pretty-big-step semantics Arthur Charguéraud INRIA October 2012 1 / 34 Motivation Formalization of JavaScript with Sergio Maeis, Daniele Filaretti, Alan Schmitt, Martin Bodin. Previous work: Semi-formal

More information

Collaborative Software Design & Development. *Collaboration*

Collaborative Software Design & Development. *Collaboration* Collaborative Software Design & Development Lecture 5 Collaborative Software Design & Development *Collaboration* Dewayne E Perry ENS 623A Office Hours: T/Th 10:00-11:00 perry @ ece.utexas.edu www.ece.utexas.edu/~perry/education/382v-s08/

More information

The Design and Implementation of Typed Scheme

The Design and Implementation of Typed Scheme The Design and Implementation of Typed Scheme Sam Tobin-Hochstadt PLT, Northeastern University Boston, MA 02115 Matthias Felleisen Abstract When scripts in untyped languages grow into large programs, maintaining

More information

Type Systems. Luca Cardelli. Microsoft Research

Type Systems. Luca Cardelli. Microsoft Research Type Systems Luca Cardelli Microsoft Research 1 Introduction The fundamental purpose of a type system is to prevent the occurrence of execution errors during the running of a program. This informal statement

More information

Deterministic Discrete Modeling

Deterministic Discrete Modeling Deterministic Discrete Modeling Formal Semantics of Firewalls in Isabelle/HOL Cornelius Diekmann, M.Sc. Dr. Heiko Niedermayer Prof. Dr.-Ing. Georg Carle Lehrstuhl für Netzarchitekturen und Netzdienste

More information

Idris, a General Purpose Dependently Typed Programming Language: Design and Implementation

Idris, a General Purpose Dependently Typed Programming Language: Design and Implementation Under consideration for publication in J. Functional Programming 1 Idris, a General Purpose Dependently Typed Programming Language: Design and Implementation EDWIN BRADY School of Computer Science, University

More information

Type and Effect Systems

Type and Effect Systems Type and Effect Systems Flemming Nielson & Hanne Riis Nielson Department of Computer Science, Aarhus University, Denmark. Abstract. The design and implementation of a correct system can benefit from employing

More information

Outline Basic concepts of Python language

Outline Basic concepts of Python language Data structures: lists, tuples, sets, dictionaries Basic data types Examples: int: 12, 0, -2 float: 1.02, -2.4e2, 1.5e-3 complex: 3+4j bool: True, False string: "Test string" Conversion between types int(-2.8)

More information

Hybrid Types, Invariants, and Refinements For Imperative Objects

Hybrid Types, Invariants, and Refinements For Imperative Objects Hybrid Types, Invariants, and Refinements For Imperative Objects Cormac Flanagan Department of Computer Science University of California, Santa Cruz Stephen N. Freund Department of Computer Science Williams

More information

Contracts as Pairs of Projections

Contracts as Pairs of Projections Contracts as Pairs of Projections Robert Bruce Findler, University of Chicago Matthias Blume, Toyota Technological Institute at Chicago University of Chicago TR-2006-01 (Expanded version of FLOPS 2006)

More information

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014 CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages Nicki Dell Spring 2014 What is a Programming Language? A set of symbols and associated tools that translate (if necessary) collections

More information

Java (12 Weeks) Introduction to Java Programming Language

Java (12 Weeks) Introduction to Java Programming Language Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short

More information

Fundamentals of Programming Languages

Fundamentals of Programming Languages A puzzle and a dilemma Suppose I want to capture/catch/slay crashing programs before they have a chance to run (=static type safety). Do I let this one go? let c = ref (fun x -> x) in c := (fun x -> x

More information

This paper should be referenced as:

This paper should be referenced as: This paper should be referenced as: Connor, R.C.H., Dearle, A., Morrison, R. & Brown, A.L. An Object Addressing Mechanism for Statically Typed Languages with Multiple Inheritance. In Proc. OOPSLA'89, New

More information

2! Multimedia Programming with! Python and SDL

2! Multimedia Programming with! Python and SDL 2 Multimedia Programming with Python and SDL 2.1 Introduction to Python 2.2 SDL/Pygame: Multimedia/Game Frameworks for Python Literature: G. van Rossum and F. L. Drake, Jr., An Introduction to Python -

More information

Pluggable Type Systems. Gilad Bracha

Pluggable Type Systems. Gilad Bracha Pluggable Type Systems Gilad Bracha The Paradox of Type Systems Type systems help reliability and security by mechanically proving program properties Type systems hurt reliability and security by making

More information

Rigorous Software Development CSCI-GA 3033-009

Rigorous Software Development CSCI-GA 3033-009 Rigorous Software Development CSCI-GA 3033-009 Instructor: Thomas Wies Spring 2013 Lecture 5 Disclaimer. These notes are derived from notes originally developed by Joseph Kiniry, Gary Leavens, Erik Poll,

More information

A SOUND TYPE SYSTEM FOR SECURE FLOW ANALYSIS

A SOUND TYPE SYSTEM FOR SECURE FLOW ANALYSIS Journal of Computer Security draft printout, (17 Sep 2009), 1 20 IOS Press 1 A SOUND TYPE SYSTEM FOR SECURE FLOW ANALYSIS Dennis Volpano Computer Science Department Naval Postgraduate School Monterey,

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

Type Checking SQL for Secure Database Access

Type Checking SQL for Secure Database Access Type Checking SQL for Secure Database Access James Caldwell 1 and Ryan Roan 2 1 Department of Computer Science, University of Wyoming, Laramie, WY 82071 2 Handel Information Technologies, 200 South 3rd

More information

Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named

More information

Scala type classes and machine learning. David Andrzejewski Bay Area Scala Enthusiasts - 1/14/2013, 1/16/2013

Scala type classes and machine learning. David Andrzejewski Bay Area Scala Enthusiasts - 1/14/2013, 1/16/2013 Scala type classes and machine learning David Andrzejewski Bay Area Scala Enthusiasts - 1/14/2013, 1/16/2013 Context: Sumo Logic Mission: Transform Machine Data into IT and Business Insights Offering:

More information

Semantics and Verification of Software

Semantics and Verification of Software Semantics and Verification of Software Lecture 21: Nondeterminism and Parallelism IV (Equivalence of CCS Processes & Wrap-Up) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification)

More information

Data Structure Reverse Engineering

Data Structure Reverse Engineering Data Structure Reverse Engineering Digging for Data Structures Polymorphic Software with DSLR Scott Hand October 28 th, 2011 Outline 1 Digging for Data Structures Motivations Introduction Laika Details

More information

Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic

Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic Lars Birkedal Rasmus Ejlers Møgelberg Rasmus Lerchedahl Petersen IT University Technical Report Series TR-00-7 ISSN 600 600 February 00

More information

Introducing Formal Methods. Software Engineering and Formal Methods

Introducing Formal Methods. Software Engineering and Formal Methods Introducing Formal Methods Formal Methods for Software Specification and Analysis: An Overview 1 Software Engineering and Formal Methods Every Software engineering methodology is based on a recommended

More information

A Grammar for the C- Programming Language (Version S16) March 12, 2016

A Grammar for the C- Programming Language (Version S16) March 12, 2016 A Grammar for the C- Programming Language (Version S16) 1 Introduction March 12, 2016 This is a grammar for this semester s C- programming language. This language is very similar to C and has a lot of

More information

Indexed Types in Object-Oriented Programming

Indexed Types in Object-Oriented Programming Indexed Types in Object-Oriented Programming Joana Campos and Vasco T. Vasconcelos University of Lisbon, Faculty of Sciences, LaSIGE Abstract. Dependent type systems allow semantic properties to be expressed

More information

CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards

CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards Course Title: TeenCoder: Java Programming Course ISBN: 978 0 9887070 2 3 Course Year: 2015 Note: Citation(s) listed may represent

More information

16 Collection Classes

16 Collection Classes 16 Collection Classes Collections are a key feature of the ROOT system. Many, if not most, of the applications you write will use collections. If you have used parameterized C++ collections or polymorphic

More information

Origin Tracking in Attribute Grammars

Origin Tracking in Attribute Grammars Origin Tracking in Attribute Grammars Kevin Williams and Eric Van Wyk University of Minnesota Stellenbosch, WG2.11, January 20-22, 2015 1 / 37 First, some advertising Multiple new faculty positions at

More information

Microphone Modem Model, and MinML Modification

Microphone Modem Model, and MinML Modification Programming Languages: Theory and Practice (WORKING DRAFT OF SEPTEMBER 19, 2005.) Robert Harper Carnegie Mellon University Spring Semester, 2005 Copyright c 2005. All Rights Reserved. Preface This is a

More information

Set-theoretic Foundation of Parametric Polymorphism and Subtyping

Set-theoretic Foundation of Parametric Polymorphism and Subtyping Set-theoretic Foundation of Parametric Polymorphism and Subtyping Giuseppe Castagna 1 Zhiwu Xu 1,2 1 CNRS, Laboratoire Preuves, Programmes et Systèmes, Univ Paris Diderot, Sorbonne Paris Cité, Paris, France.

More information

Principles of Programming Languages Topic: Introduction Professor Louis Steinberg

Principles of Programming Languages Topic: Introduction Professor Louis Steinberg Principles of Programming Languages Topic: Introduction Professor Louis Steinberg CS 314, LS,LTM: L1: Introduction 1 Contacts Prof. Louis Steinberg lou @ cs.rutgers.edu x5-3581 401 Hill TA: to be announced

More information

Making Standard ML a Practical Database Programming Language

Making Standard ML a Practical Database Programming Language Making Standard ML a Practical Database Programming Language Atsushi Ohori Katsuhiro Ueno Research Institute of Electrical Communication Tohoku University {ohori, katsu}@riec.tohoku.ac.jp Abstract Integrating

More information

CCured: Type-Safe Retrofitting of Legacy Software

CCured: Type-Safe Retrofitting of Legacy Software pdfauthor CCured: Type-Safe Retrofitting of Legacy Software GEORGE C. NECULA, JEREMY CONDIT, MATTHEW HARREN, SCOTT McPEAK, and WESTLEY WEIMER University of California, Berkeley This paper describes CCured,

More information

VDM vs. Programming Language Extensions or their Integration

VDM vs. Programming Language Extensions or their Integration VDM vs. Programming Language Extensions or their Integration Alexander A. Koptelov and Alexander K. Petrenko Institute for System Programming of Russian Academy of Sciences (ISPRAS), B. Communisticheskaya,

More information

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio. Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Names, Bindings, and Scopes A name is a symbolic identifier used

More information

Programming Language Features (cont.) CMSC 330: Organization of Programming Languages. Parameter Passing in OCaml. Call-by-Value

Programming Language Features (cont.) CMSC 330: Organization of Programming Languages. Parameter Passing in OCaml. Call-by-Value CMSC 33: Organization of Programming Languages Programming Language Features (cont.) Names & binding Namespaces Static (lexical) scopes Dynamic scopes Polymorphism Parametric Subtype Ad-hoc Parameter Passing

More information

Pizza into Java: Translating theory into practice

Pizza into Java: Translating theory into practice Pizza into Java: Translating theory into practice Martin Odersky University of Karlsruhe Philip Wadler University of Glasgow Abstract Pizza is a strict superset of Java that incorporates three ideas from

More information

Objectif. Participant. Prérequis. Remarque. Programme. C# 3.0 Programming in the.net Framework. 1. Introduction to the.

Objectif. Participant. Prérequis. Remarque. Programme. C# 3.0 Programming in the.net Framework. 1. Introduction to the. Objectif This six-day instructor-led course provides students with the knowledge and skills to develop applications in the.net 3.5 using the C# 3.0 programming language. C# is one of the most popular programming

More information

On Understanding Types, Data Abstraction, and Polymorphism

On Understanding Types, Data Abstraction, and Polymorphism 1 Computing Surveys, Vol 17 n. 4, pp 471-522, December 1985 On Understanding Types, Data Abstraction, and Polymorphism Luca Cardelli AT&T Bell Laboratories, Murray Hill, NJ 07974 (current address: DEC

More information

CSCI 3136 Principles of Programming Languages

CSCI 3136 Principles of Programming Languages CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University Winter 2013 CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University

More information

Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Wyvern: A Simple, Typed, and Pure Object-Oriented Language Wyvern: A Simple, Typed, and Pure Object-Oriented Language Ligia Nistor, Darya Kurilova, Stephanie Balzer, Benjamin Chung, Alex Potanin 1, and Jonathan Aldrich Carnegie Mellon University {lnistor, darya,

More information

The Clean programming language. Group 25, Jingui Li, Daren Tuzi

The Clean programming language. Group 25, Jingui Li, Daren Tuzi The Clean programming language Group 25, Jingui Li, Daren Tuzi The Clean programming language Overview The Clean programming language first appeared in 1987 and is still being further developed. It was

More information

LiveWeb Core Language for Web Applications. CITI Departamento de Informática FCT/UNL

LiveWeb Core Language for Web Applications. CITI Departamento de Informática FCT/UNL LiveWeb Core Language for Web Applications Miguel Domingues João Costa Seco CITI Departamento de Informática FCT/UNL Most Web Application Development is not Type Safe Heterogeneous development environments

More information

Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111

Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111 Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages Corky Cartwright Swarat Chaudhuri November 30, 20111 Overview I In OO languages, data values (except for designated non-oo

More information

Harmless Advice. Daniel S Dantas Princeton University. with David Walker

Harmless Advice. Daniel S Dantas Princeton University. with David Walker Harmless Advice Daniel S Dantas Princeton University with David Walker Aspect Oriented Programming Aspect Oriented Programming IBM - 2004 IBM reports positive results in aspect-oriented programming experiments

More information

Object-Oriented Software Specification in Programming Language Design and Implementation

Object-Oriented Software Specification in Programming Language Design and Implementation Object-Oriented Software Specification in Programming Language Design and Implementation Barrett R. Bryant and Viswanathan Vaidyanathan Department of Computer and Information Sciences University of Alabama

More information

10 The Essence of ML Type Inference

10 The Essence of ML Type Inference 10 The Essence of ML Type Inference François Pottier and Didier Rémy 10.1 What Is ML? The name ML appeared during the late seventies. It then referred to a generalpurpose programming language that was

More information

Coverability for Parallel Programs

Coverability for Parallel Programs 2015 http://excel.fit.vutbr.cz Coverability for Parallel Programs Lenka Turoňová* Abstract We improve existing method for the automatic verification of systems with parallel running processes. The technique

More information

Basic Programming and PC Skills: Basic Programming and PC Skills:

Basic Programming and PC Skills: Basic Programming and PC Skills: Texas University Interscholastic League Contest Event: Computer Science The contest challenges high school students to gain an understanding of the significance of computation as well as the details of

More information

Lines & Planes. Packages: linalg, plots. Commands: evalm, spacecurve, plot3d, display, solve, implicitplot, dotprod, seq, implicitplot3d.

Lines & Planes. Packages: linalg, plots. Commands: evalm, spacecurve, plot3d, display, solve, implicitplot, dotprod, seq, implicitplot3d. Lines & Planes Introduction and Goals: This lab is simply to give you some practice with plotting straight lines and planes and how to do some basic problem solving with them. So the exercises will be

More information

Programming and Reasoning with Side-Effects in IDRIS

Programming and Reasoning with Side-Effects in IDRIS Programming and Reasoning with Side-Effects in IDRIS Edwin Brady 19th October 2014 Contents 1 Introduction 3 1.1 Hello world............................................. 3 1.2 Outline................................................

More information

Extensible Effects An Alternative to Monad Transformers

Extensible Effects An Alternative to Monad Transformers Extensible Effects An Alternative to Monad Transformers Oleg Kiselyov Amr Sabry Cameron Swords Haskell Symposium 2013 Boston, MA Sep 23, 2013 We design and implement a library that solves the long-standing

More information

Types, Polymorphism, and Type Reconstruction

Types, Polymorphism, and Type Reconstruction Types, Polymorphism, and Type Reconstruction Sources This material is based on the following sources: Pierce, B.C., Types and Programming Languages. MIT Press, 2002. Kanellakis, P.C., Mairson, H.G. and

More information

Programming and Reasoning with Algebraic Effects and Dependent Types

Programming and Reasoning with Algebraic Effects and Dependent Types Programming and Reasoning with Algebraic Effects and Dependent Types Edwin C. Brady School of Computer Science, University of St Andrews, St Andrews, Scotland. Email: ecb10@st-andrews.ac.uk Abstract One

More information

The Structure and Interpretation of the Computer Science Curriculum

The Structure and Interpretation of the Computer Science Curriculum The Structure and Interpretation of the Computer Science Curriculum Matthias Felleisen 1, Robert B. Findler 2, Matthew Flatt 3, and Shriram Krishnamurthi 4 1 Northeastern University, Boston, MA, USA 2

More information

Detecting Software Vulnerabilities Static Taint Analysis

Detecting Software Vulnerabilities Static Taint Analysis Vérimag - Distributed and Complex System Group Universitatea Politehnica București Detecting Software Vulnerabilities Static Taint Analysis Dumitru CEARĂ Supervisors Marie-Laure POTET, Ph.D, ENSIMAG, Grenoble

More information

Math 241, Exam 1 Information.

Math 241, Exam 1 Information. Math 241, Exam 1 Information. 9/24/12, LC 310, 11:15-12:05. Exam 1 will be based on: Sections 12.1-12.5, 14.1-14.3. The corresponding assigned homework problems (see http://www.math.sc.edu/ boylan/sccourses/241fa12/241.html)

More information

The Not Quite R (NQR) Project: Explorations Using the Parrot Virtual Machine

The Not Quite R (NQR) Project: Explorations Using the Parrot Virtual Machine The Not Quite R (NQR) Project: Explorations Using the Parrot Virtual Machine Michael J. Kane 1 and John W. Emerson 2 1 Yale Center for Analytical Sciences, Yale University 2 Department of Statistics, Yale

More information

Session Types, Typestate and Security! Simon Gay! School of Computing Science! University of Glasgow!

Session Types, Typestate and Security! Simon Gay! School of Computing Science! University of Glasgow! Session Types, Typestate and Security! Simon Gay! School of Computing Science! University of Glasgow! Session Types! Type-theoretic specification of communication protocols,! so that protocol implementations

More information

Charles Dierbach. Wiley

Charles Dierbach. Wiley Charles Dierbach Wiley Contents Preface Acknowledgments About the Author XXI xxv xxvii Introduction 1 MOTIVATION 2 FUNDAMENTALS 2 1.1 What Is Computer Science? 2 1.1.1 The Essence of Computational Problem

More information

- ' +. /0 ( 1 +. ' &+. /"0 &1,

- ' +. /0 ( 1 +. ' &+. /0 &1, !"# $% &'()*++, - ' +. /0 ( 1 +. ' &+. /"0 &1,, +. 2"! public class Essai static public void main(string[] args) System.out.println("Un essai..."); System.out.println(un_calcul.somme(4,5));! 34/0- public

More information

CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output

CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output CSCE 110 Programming Basics of Python: Variables, Expressions, and nput/output Dr. Tiffani L. Williams Department of Computer Science and Engineering Texas A&M University Fall 2011 Python Python was developed

More information

Annotated bibliography for the tutorial on Exploring typed language design in Haskell

Annotated bibliography for the tutorial on Exploring typed language design in Haskell Annotated bibliography for the tutorial on Exploring typed language design in Haskell Oleg Kiselyov 1 and Ralf Lämmel 2 1 Fleet Numerical Meteorology and Oceanography Center, Monterey, CA 2 Universität

More information

Computer Programming I

Computer Programming I Computer Programming I COP 2210 Syllabus Spring Semester 2012 Instructor: Greg Shaw Office: ECS 313 (Engineering and Computer Science Bldg) Office Hours: Tuesday: 2:50 4:50, 7:45 8:30 Thursday: 2:50 4:50,

More information

Lecture 9. Semantic Analysis Scoping and Symbol Table

Lecture 9. Semantic Analysis Scoping and Symbol Table Lecture 9. Semantic Analysis Scoping and Symbol Table Wei Le 2015.10 Outline Semantic analysis Scoping The Role of Symbol Table Implementing a Symbol Table Semantic Analysis Parser builds abstract syntax

More information

Using EDA Databases: Milkyway & OpenAccess

Using EDA Databases: Milkyway & OpenAccess Using EDA Databases: Milkyway & OpenAccess Enabling and Using Scripting Languages with Milkyway and OpenAccess Don Amundson Khosro Khakzadi 2006 LSI Logic Corporation 1 Outline History Choice Of Scripting

More information

New Generation of Software Development

New Generation of Software Development New Generation of Software Development Terry Hon University of British Columbia 201-2366 Main Mall Vancouver B.C. V6T 1Z4 tyehon@cs.ubc.ca ABSTRACT In this paper, I present a picture of what software development

More information