4 ms·
> I have never had a static type checker (regardless of how sophisticated it is) help me prevent anything more than an obvious error (which should be caught in
by jgwil2 6y ago
> I have never had a static type checker (regardless of how sophisticated it is) help me prevent anything more than an obvious error (which should be caught in testing anyway).
This is the static vs dynamic type debate in a nutshell. Personally I think Typescript hits a sweet spot of static typing by default with an escape hatch (via the `any` type) when you need it. I think more self-documenting code makes the tradeoff well worth it (with the added guarantee that the documentation is correct). And most importantly, I like getting feedback from the editor as I'm typing rather than having to write code then run tests, then write some more and perhaps modify the tests, etc.
- tazjin 6y agoOn the other hand, I've worked with Erlang systems where almost all issues we saw in production would have been prevented by a type-checker. There are, however, very few ergonomic type systems. At the moment I think Rust is, sadly, the only one.
- coldtea 6y agoWhat makes it ergonomic in your opinion?
- coldtea 6y ago>Personally I think Typescript hits a sweet spot of static typing by default with an escape hatch (via the `any` type) when you need it. That has been available in Obj-C, C# and others...
- mssundaram 6y agoEven better, use `unknown` when at all possible instead of `any` - it's like `any` but you need to assert/inspect it to unwrap anything from it.
- frou_dh 6y agoIn that debate, we quite often hear something along the lines of "I can't remember the last time a static typechecker actually helped me" and that makes me imagine a fish saying they can't remember the last time that water actually helped them. Maybe the ambient help is so constant that it no longer even registers in long-term memory.
- IshKebab 6y agoIt's like saying you don't need a spell checker becuase you never make mistakes. Pure hubris.
- kazinator 6y agoNo, it's like saying "I can't remember the last time I needed to turn my document into a string literal embedded into the word processor's source code, so that a spelling error could be caught when the word processor is recompiled. I test my document using an easy-to-use run-time spell checking feature."
- jgwil2 6y agoThis is not an apt analogy at all. You don't recompile your editor to get type errors. The question is type checking vs unit tests. If your text editor can type check as you type, the feedback loop is much tighter than recompiling and rerunning and possibly modifying handwritten unit tests.