Why Only Type-hints?
If I look at most problems in the codebases I've managed, I've seen errors in performance, side-effects, security, etc. To be honest, types or not the first thing on my list. Now why do type hints improve quality? They allow the compiler to reason about the software that we make and it helps us to check our assumptions, faster than any human could do. We should allow our programming environment to help us with other aspects too. Here's an over-the-top example for Python:
- Performance: a method was slow on the production set, but another developer didn't know and used it in the UI anyway.
- Side-effects: developers are not sure if functions are pure or if it could lead to external APIs being called, so how do we handle that if there are database rollbacks?
- Security: it's not clear who is allowed to execute this function, is it only for system administrators, customer service employees, or end-users?
- Data Privacy: Is there any PII going into the data lake that is only supposed to contain anonymized data?
- Memory: This function handles incoming video files and buffers them in memory. It will break when someone uploads a 1GB video file to your tiny server.
- Intent: the intent of the original developer is completely unclear. We can use free-form comments and things like pydoc for this, but it's a horrible solution in my view.
- Tests: test systems are add-on tools to our languages, there's nothing in the language itself that allows us to ensure input/output or other kinds of tests.
Now obviously this is ugly. There's no inference or other clever things, and it builds on the annotation functionality in python which makes it only available at runtime. We want it when we are writing our software. I'm not proposing this syntax, but I do want a programming environment where we can add other hints than just type hints. It will probably never fit on one line like current type annotations do. But I do believe we will find solutions for this in the future.