Growing pains for typing in Python
Growing pains for typing in Python
Posted Jan 19, 2024 6:49 UTC (Fri) by dkg (subscriber, #55359)Parent article: Growing pains for typing in Python
Thanks, Jake, for this thoughtful and insightful article.
I wanted to weigh in briefly on the idea of whether a type system needs "full soundness" to be useful. It emphatically does not need "full soundness". I've used python's type-checking system in a far far less complete form than "full soundness" to identify (and in some cases, fix) innumerable bugs.
What's more, with even half-assed type annotations, i've managed to avoid adding scores of bugs, because the tooling helps me see what i was missing/forgetting/misunderstanding. This is especially the case for mid-to-large codebases, where i'm unable to keep the whole thing in in my head at once, but it's also true for smaller projects that i might not be working on all the time. If the part of the project gets "swapped out" mentally, and i've got decent (doesn't need to be perfect) type-checking in place, then i feel much more comfortable diving back in because i know that there are some guardrails in place.
I'd actually argue that the weak type annotations in python can behave like test suites in this way: the more you have, the safer it is to try to re-factor or make deep changes, because encoding your expectations explicitly as you write gives you a chance to avoid violating those expectations months or years later when you've forgotten all about them.
