4 ms·
I'm getting sick of hearing people complain so much about Python's type system. I'm actually in favor of strong typing, but some people grossley oversell its v
by CivBase 7y ago
I'm getting sick of hearing people complain so much about Python's type system. I'm actually in favor of strong typing, but some people grossley oversell its value - especially on HN.
The overwhelming majority of code I work with is in Python and I can't remember the last time I encountered an issue caused by invalid types. Static analysis tools, good documentation, and peer reviews (things that should be part of any critical code development) almost always prevent those sorts of issues.
Strong typing is great. Just don't exaggerate its effectiveness.
- souprock 7y agoStrong typing has hidden value that goes far beyond bug avoidance. It is tremendously important for performance. The only way to get performance out of Python is to cheat: use a not-quite-Python that violates normal Python behavior, use a hack that lets you insert C code into your Python, or simply call a few heavy-duty library functions to do all the real work.
- stjohnswarts 7y agoNone of my projects in python suffer from performance issues, because it's fast enough. Albeit I just work in the automation space. I do use C for embedded but only because we just don't have the memory capacity for python to run multiple daemons on my IoT projects, it's not because of performance.
- MagnumOpus 7y ago> simply call a few heavy-duty library functions to do all the real work Which is the main advantage of python. Since there are heavily optimised libraries for everything from optimisation to numerical analysis to ML, 99% of people don't need to attempt to be a Real Programmer and write the hand-optimised Fortran/C/assembly code themselves.
- CivBase 7y agoThe type system is only one of many issues responsible for Python's lack of performance. I understand the benefits of static typing. I'm just tired of it often being so overstated.
- takeda 7y agoYou probably meant statically typed, python already is strongly typed.
- edflsafoiewq 7y agoI can. A project I've been involved with a bit lately has several of bugs of the form "I expected X but got None" where None was a rare case. Or using `if not foo` instead of `if foo is not None`, where the actual error can occur very far away from the if statement. A type system is a good way to get static analysis and documentation :)
- CivBase 7y agoTo be fair, many languages that have static typing (Java) allow for a null value regardless of type. Systems like that wouldn't help in yout case.