3 ms·
Yes, we mostly agree. Apropos "automation is just more possibly buggy code" is also a good argument for static typing. Good static typing can express (some of
by eru 3y ago
Yes, we mostly agree.
Apropos "automation is just more possibly buggy code" is also a good argument for static typing. Good static typing can express (some of) your business logic, so that (some) invalid states are forbidden by the types.
The result is that quite a few invariants that need to be checked via tests in eg Python can be expressed in the type system in eg Haskell. The type checker already exists and is implemented as fairly battle hardened code, so this way you reduce the amount of new, possibly buggy code.
An example: in Go the convention is that when a function can go wrong, it returns a tuple of two values and exactly one of them is supposed to be the null pointer. But the compiler doesn't help you enforce that convention at all, so you need testing (and perhaps careful reasoning).
By contrast, Rust's Result type enlists the compiler to make sure that you return exactly either an error or a business-as-usual value.