<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 11.09.2015 08:24, Jukka Lehtosalo wrote:<br>
    <blockquote
cite="mid:CAA_f+LzcuThaoipmLPw0iOHX0EwHQLuQPwO1RrATNpEskp3FXg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Thu, Sep 10, 2015 at 9:42 AM, Sven
            R. Kunze <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:srkunze@mail.de" target="_blank">srkunze@mail.de</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"><span class=""> </span>If
                my variables have crappy names, so I need to add type
                hints to them, well, then, I rather fix them first.</div>
            </blockquote>
            <div><br>
            </div>
            <div>Even good variable names can leave the type ambiguous.</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Try harder then.<br>
    <br>
    <blockquote
cite="mid:CAA_f+LzcuThaoipmLPw0iOHX0EwHQLuQPwO1RrATNpEskp3FXg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> And besides, if you assume that all code is perfect or
              can be made perfect I think that you've already lost the
              discussion. Reality disagrees with you. ;-) <br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Not sure where I said this.<br>
    <br>
    <blockquote
cite="mid:CAA_f+LzcuThaoipmLPw0iOHX0EwHQLuQPwO1RrATNpEskp3FXg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div>You can't just wave a magic wand and to get every
              programmer to document their code and write unit tests.
              However, we know quite well that programmers are perfectly
              capable of writing type annotations, and tools can even
              enforce that they are present (witness all the Java code
              in existence).</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    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).<br>
    <br>
    [ Interesting, that it was that easy to exchange the parts you've
    given me ;) ]<br>
    <br>
    Btw. have you heard of code review?<br>
    <br>
    <blockquote
cite="mid:CAA_f+LzcuThaoipmLPw0iOHX0EwHQLuQPwO1RrATNpEskp3FXg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div>Tools can't verify that you have good variable names or
              useful docstrings, and people are too inconsistent or lazy
              to be relied on.</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Same can be said for type annotations.<br>
    <br>
    <blockquote
cite="mid:CAA_f+LzcuThaoipmLPw0iOHX0EwHQLuQPwO1RrATNpEskp3FXg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div>In a cost/benefit analysis it may be optimal to spent
              half the available time on annotating parts of the code
              base to get some (but necessarily limited) static checking
              coverage and spend the remaining half on writing tests for
              selected parts of the code base, for example. It's not all
              or nothing.</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    I would like to peer-review that cost/benefit analysis you've made
    to see whether your numbers are sane.<br>
    <br>
    <blockquote
cite="mid:CAA_f+LzcuThaoipmLPw0iOHX0EwHQLuQPwO1RrATNpEskp3FXg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"><span class=""><br>
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div class="gmail_extra">
                        <div class="gmail_quote">
                          <div>You get extra credit if your tests are
                            slow to run and flaky,</div>
                        </div>
                      </div>
                    </div>
                  </blockquote>
                  <br>
                </span> We are problem solvers. So, I would tell my
                team: "make them faster and more reliable".</div>
            </blockquote>
            <div><br>
            </div>
            <div>But you'd probably also ask them to implement new
              features (or *your* manager might be unhappy), and they
              have to find the right balance, as they only have 40 hours
              a week (or maybe 80 hours if you work at an early-stage
              startup :-). Having more tools gives you more options for
              spending your time efficiently.</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Yes, I am going to tell him: "Hey, it doesn't work but we got
    all/most of the types right."<br>
    <br>
    <blockquote
cite="mid:CAA_f+LzcuThaoipmLPw0iOHX0EwHQLuQPwO1RrATNpEskp3FXg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> <br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000">Granted. But you
                still don't know if your code runs correctly. You are
                better off with tests. And I agree type checking is 1
                test to perform (out of 10K).<br>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Actually a type checker can verify multiple properties
              of a typical line of code. So for 10k lines of code,
              complete type checking coverage would give you the
              equivalent of maybe 30,000 (simple) tests. :-P <br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    I think you should be more specific on this.<br>
    <br>
    Using hypothesis, e.g., you can easily increase the number of simple
    tests as well.<br>
    <br>
    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.<br>
    <br>
    Moreover, in order to add <b>reasonable</b> 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 <b>understanding</b>
    the code. And there, better variable names help a lot.<br>
    <br>
    <blockquote
cite="mid:CAA_f+LzcuThaoipmLPw0iOHX0EwHQLuQPwO1RrATNpEskp3FXg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div>It's often not cost effective to have good test
              coverage (and even 100% line coverage doesn't give you
              full coverage of all interactions). Testing can't prove
              that your code doesn't have defects -- it just proves that
              for a tiny subset of possible inputs you code works as
              expected. A type checker may be able to prove that for
              *all* possible inputs your code doesn't do certain bad
              things, but it can't prove that it does the good things.
              Neither subsumes the other, and both of these are
              approaches are useful and complementary (but incomplete).</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    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.<br>
    <br>
    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.<br>
    <br>
    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.<br>
    <br>
    <blockquote
cite="mid:CAA_f+LzcuThaoipmLPw0iOHX0EwHQLuQPwO1RrATNpEskp3FXg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div>I think that there was a good talk basically about this
              at PyCon this year, by the way, but I can't remember the
              title.</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    It'll be great to have it. :)<br>
    <br>
    Best,<br>
    Sven<br>
  </body>
</html>