Today I worked on taking the existing codebase of Sydent, which is perhaps 7 or 8 years old, and adding type annotations to it so that we could run mypy, a program which implements static type checking for Python. Adding static types to python is sort of wild. The first language I learned was Java, so I am familiar with static types and static type checking, but I never thought I’d be adding static types to Python!
I remember the first time I wrote code in a language that wasn’t statically typed (ironically, it was in Python) and how “freeing” it felt! It’s fun for small/simple projects, but the downside of all that freedom is that you are free to make serious mistakes, and the more complex/larger the codebase gets, the more likely those mistakes are. Thus the introduction of tools like mypy, to support the development of strongly-typed, verifiable Python code as Python began being adopted and used by larger and more commercial applications.
On a practical level, the process of trying type code that wasn’t written with types in mind is really interesting/frustrating/fascinating. Most of it is pretty straightforward, but there’s definitely some weirdness lurking in there. I am sure that the widespread adoption of mypy will fundamentally change python down the road. It’s fascinating to watch the language and the culture around it evolve in real-time. It reminds me once again that software is a primarily social phenomenon.