476 karma · joined May 12, 2020 (6y ago) · 570 submissions
comment 4y ago · link · parent
Typing related bugs that aren't caught in unit testing are very rare.
comment 4y ago · link · parent
So using type hints to annotate your flask api, etc. to generate docs is great. No problem.
The issue is that there have been a lot of Java developers switching to Python and they want to pretend that Python is a statically typed language (and use tools like MyPy) because it's more familar to them.
Python is not a statically typed language and treating it as one leads to terrible results. Especially in large projects.
The issue of course if that the Java developers have no point of reference on what a successful large Python project looks like. So they think they are doing great with MyPy when if you compare what they are outputting to a proper large Python project, it's pretty clear they are doing terribly.
When you use Python properly you write self contained microservices. Typing information exists but only on the external interfaces e.g. API. You also don't share business logic code between the self contained microservices because that massively decreases the maintainabily of the overall system. You show your Python code is correct by using Unit Testing and Mocking.
Basically, there is a way to do large Python projects and MyPy (and other static type checking tools) have no place in that story. It only exists to support people in making bad decisions on their codebase.
comment 4y ago · link · parent
By using a static type checker on a dynamically typed language, you have admitted you don't know what are you doing right of the bat. This means the software engineers in the project are very bad and therefore the code quality overall will also be bad.
Tools like MyPy exist to make Python appear to be more like Java to help Java developers, who aren't willing to learn how to code in a different programming paradigm.
That code will always be far worse than Python code written using the Python development paradigms.
comment 4y ago · link · parent
"And there is nothing wrong with using a type checker for your Python type annotations."
There is a lot wrong with that. Python is a dynamically typed language. If you are using a static type checker on a dynamically typed language, you are not taking advantage of the dynamic nature of the language.
You are basically not writing Python code at all. This means you get all the disadvantages of using a dynamically typed language with none of the benefits.
In summary, you have a made a very poor engineering decision.
comment 4y ago · link · parent
That's just how effective Python is done.
comment 4y ago · link · parent
You can just shoot a couple of the offending microservices dead and replace them with better implemented versions.
[Assuming there are at least 6 developers]
comment 4y ago · link · parent
When informed the maths in economics is wrong, the economists don't go and fix their maths either.
Economics is more like sociology with some random incorrect formulas written on the black board as set dressing.
Economics might in self loathing claim they are the "dismal science", but the cold hard truth is they simply speaking are not doing their jobs properly. It's a broken research field.
comment 4y ago · link · parent
Type checking is just a really poor way to ensure program correctness until you start using an exceptionally strongly typed language like Haskell.
You use types in C / C++ / Java because the compiler needs them to work not because it's a good idea.
comment 4y ago · link · parent
There are shorter more concise ways to write your programs if you are not using static typing.
If you are not writing your Python programs in the Pythonic way then you are not really using Python correctly and you do not get most of the benefits of the language.
Unit tests exist for catching bugs in Python. Type hints are for documentation not for ensuring code correctness.
Yes, there are libraries that take advantage of type hints, through they could of used other annonations and it's valid to use type hints along with those libraries.
But as soon as you are attempting to prove your program doesn't have bugs via typing rather than unit testing. You have gone wrong.
Typed Python is far more bug prone, why? Because structuring your Python code to support typing means writing considerably more lines of code.
It not the type hints themselves but it's the way you will structure your program at a high level to support them.
The more lines of code the more bugs it has. Bugs are well known to be proportion to the number of lines of source code regardless of language used or whether the language is typed or not.
comment 4y ago · link · parent
Typing encourages a large number of bad coding practices. If you can apply typing to a Python program then you are not taking advantage of the dynamic nature of the language to write simpler and shorter code.
In Python world, unit tests cover what is normally handled by typing.
comment 4y ago · link · parent
It's no different from using SQL for database access.
Basically, someone has to do a ton of upfront work designing a domain specific language for a task, in this case game scripting then it's easier for people to do the game scripting using the domain specific language than using a general purpose language.
SQL is an early example of a language designed for a specific purpose.
comment 5y ago · link · parent
The trick I used was to take an existing GB emulator, add a printf debugging statement to print out each current instruction and the registers. Add the same printf statements on mine. Then use diff on the outputs of both emulators.
It does play Pokemon. The emulator is called FireGB.
comment 5y ago · link · parent
Here's a song about it written in 2010: https://www.youtube.com/watch?v=5eBT6OSr1TI
Song's punchline: "It's absolutely true because I read about it in the daily mail /s"