▲ | crazygringo 4 days ago | |||||||
> Why do we need type checking at all? The standard answer is scale. “Small programs don’t need types,” the reasoning goes, “but large programs become unmaintainable without them.” No it's not. Type checking is a first line of defense against bugs. That's all. It's just making sure you're not accidentally passing invalid data or performing an invalid operation. And since the article gets the premise wrong, its conclusion that reducing complexity will make type checking "largely irrelevant" is therefore also wrong. | ||||||||
▲ | motorest 4 days ago | parent | next [-] | |||||||
> Type checking is a first line of defense against bugs. That's all. Exactly, and it goes way beyond that point. Static type checking turns expensive, hard-to-catch bugs that manifest only at runtime when exercising specific code paths into cheap, trivial to spot bugs that you spot at compile time. On top of that, nowadays it greatly improved developer experience as IDEs use type hints to detect and avoid bugs even before you compile the code, and even helps autocomplete code you are typing. We've been through this before. Haven't we learned this yet? | ||||||||
| ||||||||
▲ | Agraillo 4 days ago | parent | prev | next [-] | |||||||
> It's just making sure you're not accidentally passing invalid data or performing an invalid operation. To understand that this is a big deal, one sometimes needs to face the relaxed rules of their static language of choice. Delphi (and its ancestor Turbo Pascal) allows passing untyped pointers for parameters defined as typed. This behavior is actually controlled by a setting that is probably relaxed (allowed) by default. It seems it was done for convenience when using pointer arithmetic. At some point in the past, I also started logging categories of bugs (an ad-hoc taxonomy) and, if some kind of bug appeared more than once, to do something about it (like encouraging a new habit, rule, or something similar). So, after passing wrong pointers twice in a short period of time, I made it mandatory for all sources to have only typed pointers, which required some additional typing but saved me from similar bugs further on. | ||||||||
▲ | jameson 4 days ago | parent | prev [-] | |||||||
Right. Also same rationale goes to compile time vs runtime time checks -- catching type bugs before the program is executed |