4 ms·
"I do Python daily, but I also am familiar with Java and C++. In my experience with these languages I would argue that static type checking does not really help
by pmoriarty 9y ago
"I do Python daily, but I also am familiar with Java and C++. In my experience with these languages I would argue that static type checking does not really help catching bugs other than the most trivial ones."
Guido Van Rossum seems to be more enthusiastic about static type checking. He's put in a lot of effort recently in to mypy[1], a static type checker for Python.
Dropbox, the company that Guido works for, has committed to adding static type annotations to their entire 4,000,000 line codebase and checking it with mypy. As of 2016 they had done 400,000 lines[2], and 700,000 lines as of 2017 (after 18 months total).[3]
Guido also mentioned that Dropbox's desktop client team, one of the most important teams at Dropbox, has mandated that all new code have static type annotations and be checked with mypy.[2]
[1] - http://www.mypy-lang.org/ http://www.mypy-lang.org/
[2] - https://www.youtube.com/watch?v=ZP_QV4ccFHQ https://www.youtube.com/watch?v=ZP_QV4ccFHQ
[3] - https://www.youtube.com/watch?v=7ZbwZgrXnwY https://www.youtube.com/watch?v=7ZbwZgrXnwY
- neemetamm 9y agoThanks for the links! I am watching [2] at the moment and I would just like to give my perspective on how I would approach this problem. To rehash, the question in the video is that just by looking at the following code: for entry in entries: entry.data.validate() What does it do? Without context it is hard to know and one would have to search for all functions named validate(), which is hard. Or to rewrite it in statically typed language, which is impossible. The way I've been solving these situations is that I look into the unit test of the relevant function to understand what is going on. Unit tests also act as concise examples on how to use the code with example data. Also, if necessary, I can just debug the relevant unit test and step through the function and see in real-time what is going on. But I am not trying to claim that type annotations are a bad idea, I just haven't used them myself yet.