On the Expressive Power of Programming Languages 1
Historical Context Control Reduction delimiters DrScheme ( 1997) Parametricity (1983) Semantics ( 1992) ( 1990) This Progress and Revenge of the Son of R3R Scheme Preservation (1994) paper the LISP Machine ( 1999) ( 1986 ) (1991) 2
Historical Context 1991: Writes this 1994: Shriram pivots paper from CompBio after reading it 3
Historical Context 1991: Writes this 1994: Shriram pivots 2010: Essence of 2019: nothing of note. paper from CompBio after JavaScript reading it 4
Expressivity Language L’ 5
Expressivity Constructs F Language L’ Language L 6
Expressivity > Language L Language L’ 7
Expressivity Constructs F 𝜚 (compiler) Language L’ 8
Expressivity Let x = init in body Let x = ref 0 in x++ ( fun x -> body) init Let x = makeBox () in x.setRef(x.getRef + 1) 9
Eliminable Constructs 10
11
12
13
Let x = init in body 𝜚 ( Let x = init in body) => ( fun x -> 𝜚 (body)) 𝜚 (init) ( fun x -> body) init Eliminable: Example 14
Contextual Equivalence Or Observational Equivalence 15
e1 e2 16
e1 e2 Context C Context C 17
e1 e2 Context C Context C Distinguishing 18 Context
x y C(a) = ( fun x, y -> a) 1 (throw 1) Contextual Equivalence: Example 19
( fun x, y -> x) ( fun x -> x) (throw 1) ( fun x, y -> y) ( fun x -> x) (throw 1) 1 (throw 1) ⊥ Contextual Equivalence: Example 20
Expressivity 21
is expressible in if Constructs F Language L 𝜚 satisfies E1, E2, E3 There is no distinguishing context for F and 𝜚 (F). F is eliminable 22
Macro-expressivity 23
For (init, test, update, body) While (test, body) Macro expressivity: Example 24
For (init, test, update, body) For (init, test, upd, body) => init in While ( 𝜚 (test), 𝜚 (body) ++ 𝜚 (update)) While (test, body) Macro expressivity: Example 25
Polymorphic let Call-by-value STLC Expressive but Macro-inexpressive 26
Polymorphic let Let (x, e, b) => ( fun x -> subst (x, 𝜚 (e), 𝜚 (b))) 𝜚 (e) Call-by-value STLC Expressive! Expressive but Macro-inexpressive 27
AST function, not a syntactic abstraction! Let (x, e, b) => ( fun x -> subst (x, 𝜚 (e), 𝜚 (b))) 𝜚 (e) Recursive macros are not a problem! Macro-based subst implementation will generate scoped macros. subst is truly performing a compile-time computation. Expressive but Macro-inexpressive 28
What do we get? Eliminability (Macro) expressivity 29
What do we get? Eliminability State Continuations Inexpressible (Macro) expressivity Lambda Calculus 30
What do we get? Eliminability State Continuations Bad? (Macro) expressivity Lambda Calculus 31
Case Study 32
Essence of JavaScript * let x = { with (x) { a: 10, a + b + 10 b: 20, } } > 30 > { a: 10, b: 20 } * The Essence of JavaScript (2010); Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi 33
Essence of JavaScript * let x = { with (x) { a: 10, a + b + 10 b: 20, } } > 30 > { a: 10, b: 20 } Lambda Calculus + objects * The Essence of JavaScript (2010); Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi 34
Essence of JavaScript * let x = { with (x) { a: 10, a + b + 10 b: 20, } } > 40 > { a: 10, b: 20 } Not macro expressible Lambda Calculus + objects * The Essence of JavaScript (2010); Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi 35
Thanks! (call/cc (lambda (return) (while (true) (return "Power Overwhelming!")))) 36
Discussion points ● ● Expressivity as a language design Programming languages: isolated principle vs type directed language mathematical formalisms or design. complete ecosystems? ● Why is this not the prevailing way of designing languages? 37
Recommend
More recommend