Dropbox is a big user of Python. It’s our most widely used language both for backend services and the desktop client app (we are also heavy users of Go, TypeScript, and Rust). At our scale—millions of lines of Python—the dynamic typing in Python made code needlessly hard to understand and started to seriously impact productivity. To mitigate this, we have been gradually migrating our code to static type checking using mypy, likely the most popular standalone type checker for Python. (Mypy is an open source project, and the core team is employed by Dropbox.)
This post tells the story of Python static checking at Dropbox, from the humble beginnings as part of my academic research project, to the present day, when type checking and type hinting is a normal thing for numerous developers across the Python community. It is supported by a wide variety of tools such as IDEs and code analyzers.
I recently came across an article complaining about Python’s dynamic typing and couldn’t quite believe this was still the case. As it turns out, nowadays there is indeed a standardized way to do write type annotations and to type-check prior to runtime using mypy, all the while being driven forward by the good folks at Dropbox (which includes Python’s Benevolent Dictator for Life Guido van Rossum). This article provides a fascinating insider insight into the history of type-checking in Python and how it evolved in symbiosis with Dropbox’s codebase.
Correction: Python’s Ex-Benevolent Dictator for Life Guido van Rossum
Guido retired. He doesn’t work for Dropbox anymore.
How do you not believe that? It’s one of the hallmarks of the language, and keeping it dynamically typed is a hill many people have chosen to die on. Guido saw how problematic dynamic typing is in a large codebase while working at Dropbox, and he wanted to move Python towards becoming much more strongly typed. However, a large part of the Python community pushed back on the effort, and Guido relented. He also decided to step back from his work with Python and ultimately retire all together.
While I do work with Python regularly, I am fully in favor of strongly typed languages. I’m also fully in favor of compiled languages, which has lead me to using Go a lot.
Some things have to be built-in into the language or it’s cumbersome to use. That’s one of the reasons I like Julia.
If you treat Python as a yet another object oriented programming language, then yes, static typing is a good thing.
But Python is not just about objects. In functional programming people value having a small number of “rich” types (number, string, vector, dictionary) with many functions operating on them. It’s a fundamentally different approach, which uses different methods abstracting large problems (for example by eliminating state instead of categorizing data).
While it is fine to have a statically typed subset of Python for OO tasks, or a new language for that matter, I don’t think you can take a mature language with many uses and remove everything one group of users don’t like.