News for hackers. Stuff that matters.
Re:A Plea for Lean Software (1995) [pdf] by kummappp on Wednesday August 05, 2020 @09:18AM (#24060439)
Yeah, the type system helps in that, but for a unit testable product you need factory methods, which produce some valid and invalid cases. If you write simple tests for those it is a type checker on it's own and the type checker is just overhead. If I could choose my next project from two similar implementations where the other would be type checked and the other unit tested with basic datatype factors (at least) I would choose the unit tested one.

I would use typed API's though, because it saves documentation reading time and makes the editor autocomplete to work like magic.

Re:A Plea for Lean Software (1995) [pdf] by wtetzner on Wednesday August 05, 2020 @01:54PM (#24063560)
> If you write simple tests for those it is a type checker on it's own and the type checker is just overhead.

This is not true. Unit tests cannot replace a type system, just like a type system cannot replace unit tests.

You need a unit tests because a type system cannot check for all possible types of correctness.

However, unit tests can only check for the presence of bugs; they cannot prove their absence. On the other hand, a type system can prove that certain classes of errors cannot exist in the program.