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

More Decks by Michael Bernstein

Other Decks in Technology


  1. Know Your Types Michael R. Bernstein June 2014 Gotham Ruby

    Conference, NYC w michaelrbernste.in t @mrb_bk
  2. I’m Obsessed

  3. None
  4. What Are Types?

  5. “What we talk about when we talk about types” Benton,

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

  7. “Type Systems” Cardelli, 1996

  8. None
  9. Computer Science Skill 0 25 50 75 100 Homepage Design

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

    Outdatedness Bernstein’s Law
  11. “A collection of values. An estimate of the collection of

    values that a program fragment can assume during program execution.” Type
  12. int bool string int -> bool

  13. “A component of a type system. A rule stating the

    conditions under which a particular program construct will not cause forbidden errors.” Type Rule
  14. None
  15. “A collection of type rules for a typed programming language.

    Same as static type system.” Type System
  16. None
  17. “A language where good behavior is determined before execution.” Statically

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

    checked language
  19. “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
  20. “The process of finding a type for a program within

    a given type system.” Type Inference
  21. How Can Types Help Us?

  22. “Propositions as Types” Wadler, 2014

  23. None
  24. None
  25. Isomorphism

  26. iso morph

  27. equal shape

  28. Propositions are Types

  29. None
  30. Proofs are Programs

  31. Normalization of proofs is evaluation of programs

  32. None
  33. None
  34. None
  35. None
  36. None
  37. Deep Understanding

  38. Mathematical Certainty

  39. Enlightenment

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

  41. Detecting Errors

  42. Abstraction

  43. Documentation

  44. Safety

  45. So Much More!

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

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

  48. None
  49. “Typed Scheme: From Scripts to Programs” Tobin-Hochstadt, 2010

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

  51. Gradual Typing

  52. “…safe interoperability between typed and untyped portions of a single

    program” ! - Sam Tobin-Hochstadt
  53. “Dynamic Inference of Static Types for Ruby” An, Chaudhuri, Foster,

    Hicks, 2011
  54. “…constraint-based dynamic type inference, a technique that infers static types

    based on dynamic program executions.”
  55. None
  56. “The Ruby Type Checker” Ren, Toman, Strickland, Foster 2013

  57. “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.”
  58. None
  59. Challenges

  60. “Experience from Developing the Dialyzer: A Static Analysis Tool Detecting

    Defects in Erlang Applications” Sagonas, 2005
  61. “…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.”
  62. Conclusions

  63. Types and Type Systems Are Really, Really Cool

  64. Types Are A Prism

  65. A Type System Can Be A Guide

  66. Let’s Push It Forward

  67. Thank You w michaelrbernste.in t @mrb_bk