Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>If you're writing good unit tests already, why are you running into so many type issues?

>If you already have to spend time writing tests, why spend more writing types?

Because unit tests and types solve different problems and if you use one as a substitute for the other, you're doing it wrong.



What problem is types solving that aren't solved by the combination of function documentation, sanitizing external input, and unit testing?


Types define explicit boundaries for application data structures, tests verify software behavior at run-time, they both provide unique benefits that cannot be achieved with either alone, and they in-fact greatly compliment each-other.

Types exponentially reduce the set of possible inputs a function can receive, thus greatly reducing the number of tests that need to be written to achieve the same level of safety. Types are also much more precise and less brittle than tests, they establish clear contracts that reflect the actual structure of the program whereas tests provide assurance that some minimum subset of behavior is correct enough for the software to meet the expectations of users.

Ultimately, a lack of types is a form of technical debt because the data structures do exist whether you spend the time to formally acknowledge them or not.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: