6 ms·
Python type system is improving. Another point in this ease of use vs type safety spectrum is python -> type safe language static compilation. I don't know whi
by adsharma 6y ago
Python type system is improving. Another point in this ease of use vs type safety spectrum is python -> type safe language static compilation.
I don't know which one is the best. So I've been experimenting with several.
https://github.com/adsharma/py2many https://github.com/adsharma/py2many
- dagmx 6y agoIs the Python type system improving or is it the type annotation system that's improving? Big difference between the two.
- adsharma 6y agoThe lack of algebraic data types is what python gets criticisms about. That situation is improving, but I would have preferred match to be an expression rather than a statement. What else is missing in the python3 type system?
- dagmx 6y agoActual static typing and forced type checking.
- adsharma 6y agoI get that you're not particularly excited about gradual typing and the fact that type checkers are optional and live in a separate ecosystem from the interpreter/language runtime. I actually like the fact that python code without type annotations continues to work as before and allows for easy transcription of ideas into testable code. If a certain use case requires "forced" type checking, it shouldn't be hard to write a lint rule that disallows code from being committed if there are type checking errors, including missing type annotations.
- dagmx 6y agoThe issue though is that Python's type annotation is not a substitute for type checking. Annotations are optional and can be inaccurate. That's fine, this is part of the design of Python. However strict type systems are a benefit of other languages, that may not fit Python. Type annotation shouldn't be considered an alternative to a type system.
- dragonwriter 6y ago> Is the Python type system improving or is it the type annotation system that's improving? Both. (The type annotation system is deeply tied to the type system, since the latter is what is statically verified, but there are improvements both in what can be checked—the type system—and how that is expressed/annotated.)
- dagmx 6y agoDo you have examples of how the type system (not annotations) have been improved?
- dragonwriter 6y agoIt's important to understand that the type systems for Python are not really an inherent feature of Python, but the systems enforced by each of the static checkers (which tend to adopt each other's advancements and drive syntactic support into the core system of annotations, so there's a common baseline advancing with the individual systems). A recent advancement in one of those type systems would be pylance (actually pyright, since that's the typechecker for the pylance language server) support for higher-kinded type variables [0]. Mypy, I believe, has identified this as a thing to support, too. An example of an improvement in annotations specifically to enable type system improvements that require supporting syntax improvement is PEP 646 support for Variadic Generics. [1] Even though it is in draft, pyright has already landed support for it for the type system improvements motivating it. [2] [0] item #4, https://devblogs.microsoft.com/python/pylance-introduces-five-new-features-that-enable-type-magic-for-python-developers/ https://devblogs.microsoft.com/python/pylance-introduces-fiv... [1] https://www.python.org/dev/peps/pep-0646/ https://www.python.org/dev/peps/pep-0646/ [2] https://github.com/microsoft/pyright/releases/tag/1.1.107 https://github.com/microsoft/pyright/releases/tag/1.1.107
- dagmx 6y agoYou're continuing to describe improvements in the annotation checking ecosystem. I'm specifically asking about improvements in the type system. Again, two very different things that shouldn't be conflated.