On the Expressive Power of Programming Languages 1 Historical - - PowerPoint PPT Presentation

on the expressive power
SMART_READER_LITE
LIVE PREVIEW

On the Expressive Power of Programming Languages 1 Historical - - PowerPoint PPT Presentation

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)


slide-1
SLIDE 1

On the Expressive Power

  • f Programming Languages

1

slide-2
SLIDE 2

Historical Context

This paper (1991)

Reduction Semantics (1992) R3R Scheme (1986) DrScheme (1997) Control delimiters (1990) Revenge of the Son of the LISP Machine (1999) Progress and Preservation (1994) Parametricity (1983) 2

slide-3
SLIDE 3

Historical Context

1991: Writes this paper 1994: Shriram pivots from CompBio after reading it 3

slide-4
SLIDE 4

Historical Context

1991: Writes this paper 1994: Shriram pivots from CompBio after reading it 2010: Essence of JavaScript 2019: nothing of note. 4

slide-5
SLIDE 5

Expressivity

Language L’

5

slide-6
SLIDE 6

Expressivity

Language L’ Constructs F Language L

6

slide-7
SLIDE 7

Expressivity

Language L Language L’

>

7

slide-8
SLIDE 8

Expressivity

Constructs F Language L’

8

𝜚(compiler)

slide-9
SLIDE 9

Expressivity

9

Let x = init in body (fun x -> body) init Let x = ref 0 in x++ Let x = makeBox () in x.setRef(x.getRef + 1)

slide-10
SLIDE 10

Eliminable Constructs

10

slide-11
SLIDE 11

11

slide-12
SLIDE 12

12

slide-13
SLIDE 13

13

slide-14
SLIDE 14

14

Let x = init in body (fun x -> body) init

Eliminable: Example

𝜚(Let x = init in body) => (fun x -> 𝜚(body)) 𝜚(init)

slide-15
SLIDE 15

Contextual Equivalence

Or Observational Equivalence

15

slide-16
SLIDE 16

e1 e2

16

slide-17
SLIDE 17

e1 e2 Context C Context C

17

slide-18
SLIDE 18

e1 e2 Context C Context C Distinguishing Context

18

slide-19
SLIDE 19

Contextual Equivalence: Example

19

x y C(a) = (fun x, y -> a) 1 (throw 1)

slide-20
SLIDE 20

Contextual Equivalence: Example

20

(fun x, y -> x) (fun x -> x) (throw 1) (fun x, y -> y) (fun x -> x) (throw 1) 1 (throw 1) ⊥

slide-21
SLIDE 21

Expressivity

21

slide-22
SLIDE 22

Constructs F is expressible in Language L if F is eliminable There is no distinguishing context for F and 𝜚(F).

22

𝜚 satisfies E1, E2, E3

slide-23
SLIDE 23

23

Macro-expressivity

slide-24
SLIDE 24

Macro expressivity: Example

For (init, test, update, body) While (test, body)

24

slide-25
SLIDE 25

Macro expressivity: Example

For (init, test, update, body) While (test, body)

For (init, test, upd, body) => init in While (𝜚(test), 𝜚(body) ++ 𝜚(update))

25

slide-26
SLIDE 26

Expressive but Macro-inexpressive

Call-by-value STLC

26

Polymorphic let

slide-27
SLIDE 27

Expressive but Macro-inexpressive

Let (x, e, b) => (fun x -> subst(x, 𝜚(e), 𝜚(b))) 𝜚(e) Call-by-value STLC Expressive!

27

Polymorphic let

slide-28
SLIDE 28

Expressive but Macro-inexpressive

Let (x, e, b) => (fun x -> subst(x, 𝜚(e), 𝜚(b))) 𝜚(e) AST function, not a syntactic abstraction!

Recursive macros are not a problem! Macro-based subst implementation will generate scoped macros. subst is truly performing a compile-time computation.

28

slide-29
SLIDE 29

What do we get?

29

Eliminability (Macro) expressivity

slide-30
SLIDE 30

What do we get?

30

Eliminability (Macro) expressivity Lambda Calculus State Continuations

Inexpressible

slide-31
SLIDE 31

What do we get?

31

Eliminability (Macro) expressivity Lambda Calculus State Continuations

Bad?

slide-32
SLIDE 32

Case Study

32

slide-33
SLIDE 33

Essence of JavaScript*

33

let x = { a: 10, b: 20, } > { a: 10, b: 20 } with (x) { a + b + 10 } > 30

* The Essence of JavaScript (2010); Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi

slide-34
SLIDE 34

Essence of JavaScript*

34

let x = { a: 10, b: 20, } > { a: 10, b: 20 } with (x) { a + b + 10 } > 30

* The Essence of JavaScript (2010); Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi

Lambda Calculus + objects

slide-35
SLIDE 35

Essence of JavaScript*

35

let x = { a: 10, b: 20, } > { a: 10, b: 20 } with (x) { a + b + 10 } > 40

* The Essence of JavaScript (2010); Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi

Lambda Calculus + objects

Not macro expressible

slide-36
SLIDE 36

Thanks!

36

(call/cc (lambda (return) (while (true) (return "Power Overwhelming!"))))

slide-37
SLIDE 37

Discussion points

  • Expressivity as a language design

principle vs type directed language design.

  • Why is this not the prevailing way of

designing languages?

  • Programming languages: isolated

mathematical formalisms or complete ecosystems?

37