On 11.09.2015 08:24, Jukka Lehtosalo wrote:
Try harder then.
Not sure where I said this.
You can't just wave a magic wand and to get every programmer to add
type annotations to their code. However, we know quite well that
programmers are perfectly capable of writing unit tests, and tools
can even enforce that they are present (witness coverage tools and
hooks in SCM systems preventing it from dropping).
[ Interesting, that it was that easy to exchange the parts you've
given me ;) ]
Btw. have you heard of code review?
Same can be said for type annotations.
I would like to peer-review that cost/benefit analysis you've made
to see whether your numbers are sane.
Yes, I am going to tell him: "Hey, it doesn't work but we got
all/most of the types right."
I think you should be more specific on this.
Using hypothesis, e.g., you can easily increase the number of simple
tests as well.
What I can tell is that most of the time, a variable carries the
same type. It is really convenient that it doesn't have to but most
of the time it does. Thus, one test run can probably reveal a
dangerous type mistake. I've seen code where that is not the case
indeed and one variable is either re-used or accidentally have
different types. But, well, you better stay away from it anyway
because most of the time it's very old code.
Moreover, in order to add reasonable type annotations you
would probably invest equal amount of time that you would invest to
write some tests for it. The majority of time is about understanding
the code. And there, better variable names help a lot.
I fully agree on this. Yet I don't need type annotations. ;) A
simple test running a typechecker working at 40%-60% (depending on
whom you ask) efficiency suffices at least for me.
I would love to see better typecheckers rather than cluttering our
code with some questionable annotations; btw. of which I don't know
of are necessary at all.
Don't be fooled by the possibility of dynamic typing in Python. Just
because it's possible doesn't necessarily mean it's the usual thing.
It'll be great to have it. :)
Best,
Sven