DEV Community

Discussion on: Convince me that types are awesome

Collapse
 
johncip profile image
jmc

I wouldn't try to convince anyone to use types. Or to avoid them, either. They're useful. But silver bullets are expensive. As I see it:

Pros:

  • annotating types is often cheap
  • you can't forget to check (i.e. what type systems guarantee, they guarantee fully)
  • better IDE hints
  • they serve as a rough documentation for libraries
  • worry-free refactoring

Cons:

  • typecheckers check precisely the things that are easy for an algorithm to check, i.e. nothing to do with your problem domain
    • you can fix some of that by representing your domain as types, but then your algorithms aren't reusable
  • you probably still have null references
    • you can fix that (to a degree) with option/maybe/whatever... which raises the cost of writing code
  • "static" bugs like typos and passing in arguments of the wrong type are easy to fix