Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Know Your Types

Know Your Types

GoRuCo 2014

Michael Bernstein

June 21, 2014
Tweet

More Decks by Michael Bernstein

Other Decks in Technology

Transcript

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

    View full-size slide

  2. I’m Obsessed

    View full-size slide

  3. What Are Types?

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  6. “Type Systems”
    Cardelli, 1996

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  10. int
    bool
    string
    int -> bool

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. “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

    View full-size slide

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

    View full-size slide

  17. How Can Types
    Help Us?

    View full-size slide

  18. “Propositions as Types”
    Wadler, 2014

    View full-size slide

  19. Propositions are Types

    View full-size slide

  20. Proofs are Programs

    View full-size slide

  21. Normalization of proofs is
    evaluation of programs

    View full-size slide

  22. Deep Understanding

    View full-size slide

  23. Mathematical Certainty

    View full-size slide

  24. Enlightenment

    View full-size slide

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

    View full-size slide

  26. Detecting Errors

    View full-size slide

  27. Documentation

    View full-size slide

  28. So Much More!

    View full-size slide

  29. Types and Ruby
    (But Really Dynamic
    Languages in General)

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  33. Gradual Typing

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  38. “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.”

    View full-size slide

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

    View full-size slide

  40. “…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.”

    View full-size slide

  41. Types and Type
    Systems Are Really,
    Really Cool

    View full-size slide

  42. Types Are A Prism

    View full-size slide

  43. A Type System
    Can Be A Guide

    View full-size slide

  44. Let’s Push It
    Forward

    View full-size slide

  45. Thank You
    w michaelrbernste.in
    t @mrb_bk

    View full-size slide