Slide 1

Slide 1 text

Know Your Types Michael R. Bernstein June 2014 Gotham Ruby Conference, NYC w michaelrbernste.in t @mrb_bk

Slide 2

Slide 2 text

I’m Obsessed

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

What Are Types?

Slide 5

Slide 5 text

“What we talk about when we talk about types” Benton, 2014

Slide 6

Slide 6 text

“We don't talk about types, we argue about them.”

Slide 7

Slide 7 text

“Type Systems” Cardelli, 1996

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Computer Science Skill 0 25 50 75 100 Homepage Design Outdatedness Computer Science Skill vs. Homepage Design Outdatedness

Slide 10

Slide 10 text

Computer Science Skill 0 25 50 75 100 Homepage Design Outdatedness Bernstein’s Law

Slide 11

Slide 11 text

“A collection of values. An estimate of the collection of values that a program fragment can assume during program execution.” Type

Slide 12

Slide 12 text

int bool string int -> bool

Slide 13

Slide 13 text

“A component of a type system. A rule stating the conditions under which a particular program construct will not cause forbidden errors.” Type Rule

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

“A collection of type rules for a typed programming language. Same as static type system.” Type System

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

“A language where good behavior is determined before execution.” Statically checked language

Slide 18

Slide 18 text

“A language where good behavior is enforced during execution.” Dynamically checked language

Slide 19

Slide 19 text

“The process of checking a program before execution to establish its compliance with a given type system and therefore to prevent the occurrence of forbidden errors.” Typechecking

Slide 20

Slide 20 text

“The process of finding a type for a program within a given type system.” Type Inference

Slide 21

Slide 21 text

How Can Types Help Us?

Slide 22

Slide 22 text

“Propositions as Types” Wadler, 2014

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Isomorphism

Slide 26

Slide 26 text

iso morph

Slide 27

Slide 27 text

equal shape

Slide 28

Slide 28 text

Propositions are Types

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Proofs are Programs

Slide 31

Slide 31 text

Normalization of proofs is evaluation of programs

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Deep Understanding

Slide 38

Slide 38 text

Mathematical Certainty

Slide 39

Slide 39 text

Enlightenment

Slide 40

Slide 40 text

“Types and Programming Languages” a.k.a ‘TAPL’ Pierce, 2002

Slide 41

Slide 41 text

Detecting Errors

Slide 42

Slide 42 text

Abstraction

Slide 43

Slide 43 text

Documentation

Slide 44

Slide 44 text

Safety

Slide 45

Slide 45 text

So Much More!

Slide 46

Slide 46 text

Types and Ruby (But Really Dynamic Languages in General)

Slide 47

Slide 47 text

“A Practical Optional Type System for Clojure” Bonnaire-Sergeant,2012

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

“Typed Scheme: From Scripts to Programs” Tobin-Hochstadt, 2010

Slide 50

Slide 50 text

“Gradual Typing for Functional Languages” Siek & Taha, 2006

Slide 51

Slide 51 text

Gradual Typing

Slide 52

Slide 52 text

“…safe interoperability between typed and untyped portions of a single program” ! - Sam Tobin-Hochstadt

Slide 53

Slide 53 text

“Dynamic Inference of Static Types for Ruby” An, Chaudhuri, Foster, Hicks, 2011

Slide 54

Slide 54 text

“…constraint-based dynamic type inference, a technique that infers static types based on dynamic program executions.”

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

“The Ruby Type Checker” Ren, Toman, Strickland, Foster 2013

Slide 57

Slide 57 text

“RTC is designed so programmers can control exactly where type checking occurs: type-annotated objects serve as the “roots” of the type checking process, and unan- notated objects are not type checked.”

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Challenges

Slide 60

Slide 60 text

“Experience from Developing the Dialyzer: A Static Analysis Tool Detecting Defects in Erlang Applications” Sagonas, 2005

Slide 61

Slide 61 text

“…testing, no matter how thorough, cannot of course detect all software defects. Tools that complement testing, such as static analyzers, have their place in software development regardless of language.”

Slide 62

Slide 62 text

Conclusions

Slide 63

Slide 63 text

Types and Type Systems Are Really, Really Cool

Slide 64

Slide 64 text

Types Are A Prism

Slide 65

Slide 65 text

A Type System Can Be A Guide

Slide 66

Slide 66 text

Let’s Push It Forward

Slide 67

Slide 67 text

Thank You w michaelrbernste.in t @mrb_bk