Skip to content

Instantly share code, notes, and snippets.

@default-kramer
Created August 9, 2018 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save default-kramer/4d95c039dc23462529376fbbfaa83a0c to your computer and use it in GitHub Desktop.
Save default-kramer/4d95c039dc23462529376fbbfaa83a0c to your computer and use it in GitHub Desktop.
Talk I gave about Contracts vs Types
#lang slideshow
(require slideshow/code)
(set-margin! 20)
(current-font-size 36) ; default is 32
(slide
#:title "My Perspective"
(item "A long-time fan of static types")
(item "Respect that very good programmers disagree")
(item "Liking contracts now due to recent Racket project"))
(slide
#:title "A Basic Contract in Racket"
(typeset-code
#'(begin
(define amount?
(and/c number? positive?))
(define/contract (deposit account amount)
(-> account? amount? account?)
(error "not implemented"))))
(item "This is an unambiguous notation")
(item "That matches the code"))
(slide
#:title "Static Typing Benefits"
(item "Helps me understand code as I'm writing it")
'next
(item "Helps me understand the original author's intent")
'next
(item "Helps me reason about the code")
'next
(item "Ensures a minimum level of documentation and code quality")
'next
(item (it "Contracts work just as well for these things!")))
(slide
#:title "Static Typing Benefits"
(item "Helps me refactor or modify existing code")
'next
(item "Exploring the impact of a potential code change")
'next
(item (it "Contracts work depending on your test coverage")))
(slide
#:title "Static Typing Pains"
(item "Can be tedious to prove things to the type checker")
'next
(item "Requires the entire program to type check"))
(slide
#:title "Conclusion"
(item "Static Typing and Contracts solve a lot of the same problems")
(item "Each has its own strengths and weaknesses, but these differences seem minor now"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment