You should never be using static typing with a scripting language like Python or Ruby.
Dynamically typed code is 1/3rd the size of statically typed code, that means that one developer who is using dynamic typing is equivalent to 3 developers using statically typed code via MyPy.
Since the code is 1/3rd of the size it contains 1/3rd of the bugs.
This is confirmed by all the studies that have been done on the topic.
If you use a static type checking with Python, you have increased your development time by 3 and your bug count by 3.
Static typing's advantage is that the code runs a lot faster but that's only true if the language itself is statically typed. So with Python you have just screwed up.
Ah no I meant a proper peer reviewed source. The claim that untyped code has fewer bugs is completely bonkers, so I was quite sure that no such source existed.
Why do you think microsoft, google and facebook are all in the business of typechecking python? If typechecking would actually introduce bugs, it'd be better not doing it right?
Using github for statistics is flawed. There are millions of 10 line js libraries. Yes it's easy to not make type mistakes in 10 lines. I suppose that type errors increase more than linearly with size.
> The claim that untyped code has fewer bugs is completely bonkers
Not really. It is, however, quite expensive to measure, because dynamic typing really shines at the evolution of software, that is being able to respond fast to changing requirements. Legos vs play-doh: https://weblog.jamisbuck.org/2008/11/9/legos-play-doh-and-pr...
> Why do you think microsoft, google and facebook are all in the business of typechecking
A billion flies can't be wrong? Companies with unlimited amount of money are not the right place to search for good practices. Both Facebook and Google became flush with cash way before modern type obsession. Sure, once you are a multi-billion dollar company slowing down can be a good thing. But you need to get there first.
> If typechecking would actually introduce bugs, it'd be better not doing it right?
If sugar caused us to die sooner, we'd be better to eating too much if it, right? And yet, here we are.
"The claim that untyped code has fewer bugs is completely bonkers"
There are plenty of academic sources that will tell you that the number of bugs in a program is directly proportional to the number of lines in the program and static typing has no effect on this.
Additionally, statically typed code involves large amounts of boilerplate code in the form of abstract base classes, interfaces, generics, templating, etc. It's a very verbose code style.
It's your turn, find an academic source to backup your claim that static typing reduces the number of bugs. Cause it just isn't true.
Microsoft, google and Facebook have a lot of programmers coming from languages with static typing and want to make Python more familiar.
It's a far distance away from anything resembling good practice.
Actual Python houses typically don't use static typing.
Given that type hints are a new language feature in Python, please explain to me how these Python houses used static typing when type hints didn't exist?
> Given that type hints are a new language feature in Python, please explain to me how these Python houses used static typing when type hints didn't exist?
They've existed since 2015… please explain me how 2015 is "new"?
I have experience in working on statically typed Python codebases, it's just obviously inferior.
I'll go further and tell you the most common reason for using static typing is to allow the codebase to be a monolith like it's still the 90s. You shouldn't be trying to build a monolith in a scripting language it's a recipe for disaster.
I'm a polyglot, I'm exactly the sort of person who should be commenting.
Does it surprise you that static typing is often a poor choice?
Static typing is something to be used when the performance of your code is important. I've done 40 Gbits/sec network traffic processing, certainly static typing is used for that.
Your standard business CRUD app? Usually dynamic is the better choice.
> I have experience in working on statically typed Python codebases, it's just obviously inferior.
Maybe they just were inferior projects?
I've used a library where every function just accepted "args, *kwargs" and no documentation was given. In that case it's not really the fault of the language that it sucks. It could be a similar case for you.
> I'm a polyglot, I'm exactly the sort of person who should be commenting.
Ok I speak 3 languages fluently and 1 more so-so… But what does this have to do with python typing????
In fact most people who study literature and languages don't know much about python types.
> Does it surprise you that static typing is often a poor choice?
No because it isn't true.
> Static typing is something to be used when the performance of your code is important.
We can all agree that python isn't something to use when performances are very important.
> Your standard business CRUD app? Usually dynamic is the better choice.
Ok. That's not what I do though.
Have you done any C and C++? You know how people prefer doing a list in C++ with a template rather than a list of void in C? Same thing in python. But perhaps you haven't experience in this field either?
That seems to completely forget the fact that libraries exist, that A LOT of bugs can happen calling libraries, and that you're not really supposed to unit test libraries, they are supposed to have their own tests.
Unit tests test the parts of the library that are in use implicitly.
As does integration testing, user acceptance testing and whole system testing (QA engineers, frontend testing, etc.)
Nothing has been forgotten. Python isn't Java, nor should you develop your Python code as if it were Java. Python has it's own software development practices that take advantage of the language's strengths including dynamic typing.
It you don't know how to work with a dynamically typed language properly, that's on you. And I guarantee you will get poor results pretending it's a statically typed language.
> It you don't know how to work with a dynamically typed language properly, that's on you. And I guarantee you will get poor results pretending it's a statically typed language.
Insulting me won't make you a better developer nor a better person :)
Getting started with type hints is not easy, but it can be done incrementally and it is worth it.
If you haven't used them, please learn before insulting people who are more experienced than you.
Using static typing in a dynamically typed language will always make you a poor software engineer who doesn't understand the tools they use nor the engineering trade-offs involved.
But sure continue to hammer in nails with a screwdriver, it's only your own time you are wasting.
And I've noticed you failed to provide any sources whatsoever for your nonsense.
> And I've noticed you failed to provide any sources whatsoever for your nonsense.
As opposed to your 404 "peer reviewed paper"? :D
> Using static typing in a dynamically typed language will always make you a poor software engineer
Making broad statements about things you've never used yourself just makes you an arrogant guy on the internet who is quite likely to be a poor software engineer with a big ego.
Your "sources" were a blog with opinions based on questionable statistics methods and a stackoverflow with a 404 link.
> My wages disagree with that statement. But hey, we can't all be 10x.
Just a hint: this screams insecurity.
Wealth does not correlate with knowledge.
Especially since you don't even use type hints, so you have no professional experience with them. Just an ill formed opinion by reading blogs and comments.
> Did it ever occur to you to think about why people use scripting languages or what advantages they have over regular programming languages?
No compilation time? Very complete standard library? Opt-in typing? Good introspection? Numpy?
> Of course not, you are used to statically typed languages and are blinded to the idea that there are other ways to develop software.
I was doing python long before type hints existed, and I assure you they are an advantage. Now, I understand you lack the expertise to realise that. I'm just saying that insulting me won't make you correct.
> I'm guessing you did a search for sources to backup what you are saying and found out pretty quickly that they don't exist.
I did not bother. The fact that microsoft, google and facebook invest money into it is proof enough. You reject it because you're being irrational.
> Static typing in Python is a practice based entirely in common ignorance not reality.
I wish I could sound so bold and certain when being wrong!
Yes everybody knows what a cargo cult is. It's not some sort of intellectual remark. More of a random thing to say on the internet when you have no real arguments.
But good to know you can find sources… when they happen to exist :)
No offense, but it's like a textbook on awful debates.
Your best arguments are: "big guys are doing it therefore it's good for me too" (argument from authority) and "I tried both and decided only one is good" (argument from authority/anecdotal evidence). Plus a ton of ad hominems.
Please see Raymond Hettinger's keynote on efficiently handling bugs[0]. He makes the case that static type checking is a boon for Python except for in specific programs that make extensive use of covariant and/or contravariant types.
> You should never be using static typing with a scripting language like Python or Ruby.
You should use it where it makes sense, and not where it doesn’t. I haven’t used any of Ruby’s type checkers, but Python makes this easy enough; make what has a reason to be dynamic dynamic, and have static safety rails everywhere else.
(This is true with many “statically typed” languages that have dynamic escape hatches, too, not just traditionally “scripting” languages.)
Dynamically typed code is 1/3rd the size of statically typed code, that means that one developer who is using dynamic typing is equivalent to 3 developers using statically typed code via MyPy.
Since the code is 1/3rd of the size it contains 1/3rd of the bugs.
This is confirmed by all the studies that have been done on the topic.
If you use a static type checking with Python, you have increased your development time by 3 and your bug count by 3.
Static typing's advantage is that the code runs a lot faster but that's only true if the language itself is statically typed. So with Python you have just screwed up.