Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



> Dynamically typed code is 1/3rd the size of statically typed code,

This is absolutely not true.

> Since the code is 1/3rd of the size it contains 1/3rd of the bugs.

That is made up and contrary to all empirical evidence I've ever collected.

I'd be curious if you have a source, but I doubt it.


Anyone with experience of writing both dynamic typed and statically typed can tell you that.

Infact, you could just try it out for yourself.

But here is your internet source for this blatantly obvious fact: https://games.greggman.com/game/dynamic-typing-static-typing...


I do have such experience and I really can't tell that. Which is why I wondered if anyone else was in fact saying that.

> But here is your internet source for this blatantly obvious fact: https://games.greggman.com/game/dynamic-typing-static-typing...

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.

https://stackoverflow.com/questions/2898571/basis-for-claim-...

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.


Not across different languages. Create a new version of Java that requires an empty line between each line containing text and bugs won’t double.


Please don't reply multiple times to the same thing.

> Actual Python houses typically don't use static typing.

If you had ever developed python professionally, you'd know this to be untrue.

Also your "paper" points to a 404 page.


I have developed in a lot of Python houses.

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?

I'm all ears.


> 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"?


Python has been around since 1991. I'm little bit more experienced than you.


You seem to have no experience with type hints… You could have acquired this experience but didn't.

No shame, but you are not the most qualified person to comment on typing.

Also python3 is from 2008, and it's effectively a different programming language.


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?


It's called reading the libraries documentation.

Polyglot as in multiple programming languages.

I'm afraid it is true. Knowing the limitations of the tools you use is important. And you clearly do not.

Yes, I've done programing expensive networking hardware in C. I think you are missing that I know a lot more than you.

Tagged values aka dynamic typing is an excellent approach to doing a list from the developer's perspective.

If you think dynamic typing is like using void pointer in C you are very much mistaken.


> It's called reading the libraries documentation.

You ever tried to read haskell's documentation? You search functions by their type signature.

> Polyglot as in multiple programming languages.

lol ok.

> I'm afraid it is true. Knowing the limitations of the tools you use is important.

I agree. But to know the limitations one must know the tools first.

> And you clearly do not.

Having used both things gives me more knowledge than NOT having used both things.

> I've done programing expensive networking hardware in C.

I don't think expensiveness of the rig and skill correlates… are iphone developers better than android developers because iphones cost more?

> I think you are missing that I know a lot more than you.

Ah yes a "polyglot" who speaks just english. A true renaissance man.

> If you think dynamic typing is like using void pointer in C you are very much mistaken.

It's kinda-like-it, conceptually. I've written a compiler and an interpreter, I know how they work.


> most common reason for using static typing is to allow the codebase to be a monolith like it's still the 90s

This is so true. Static typing shines when you have a very complicated deeply nested system. And that's what most teams are naturally end up creating.

But how about not building the complicated system in the first place? Most of complexity in modern software is accidental.


> But how about not building the complicated system in the first place?

"For every complex problem, there's a solution that is simple, neat, and wrong."


Read it carefully. Complicated is not the same as complex.


A person judging a solution he doesn't know to a problem he doesn't know… How well reasoned.


"If typechecking would actually introduce bugs, it'd be better not doing it right?"

Correct if you misapply a tool to the wrong situation you get poor or negative results.

The right tools are unit testing, integration testing, uat and automated whole system testing.


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.


I'm sure you could find it on Google Scholar. I'm not your personal googler.

My wages disagree with that statement. But hey, we can't all be 10x.

Did it ever occur to you to think about why people use scripting languages or what advantages they have over regular programming languages?

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'm guessing you did a search for sources to backup what you are saying and found out pretty quickly that they don't exist.

Static typing in Python is a practice based entirely in common ignorance not reality.


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!


"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."

Basically, you are saying you are a cargo cultist rather than a serious software developer.

You fail to understand that the software practices of large multi-national companies are rarely good.

Good luck flying your plane: https://www.abyssapexzine.com/2020/03/cargo-cult/


> Basically, you are saying you are a cargo cultist rather than a serious software developer.

No. I'm saying I tried both ways and I know advantages and disadvantages and I'm capable of deciding by myself.

You on the other hand did not try both but feign expertise.

> Good luck flying your plane: https://www.abyssapexzine.com/2020/03/cargo-cult/

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.

To be fair, your opponent isn't very different.


Awful debate indeed.

I asked for sources and got a 404 link as a response.

I'm told that I earn less money, hence I'm not as good (despite the other person having no idea of how much i earn).

> To be fair, your opponent isn't very different.

And yet, you felt the need to respond to me…


You literally told me that you are a cargo cultist and your words should not to be listened to in your previous comment.

No one who has really tried both would conclude that static typing is better hence I know you are lying. :p


> You literally told me that you are a cargo cultist and your words should not to be listened to in your previous comment.

I did no such thing. But after hours of you writing lies, I'm not surprised you wrote another one.

> No one who has really tried both would conclude that static typing is better hence I know you are lying. :p

In 10-15 years, when you will actually have some non-made-up programming experience, you will agree with me :)


I don't remember writing any lies. Additionally, we can just read what you read several comments ago. So what do you think you are playing at?

Nah, I'm more qualified than you. You just don't want to hear that you are wrong.


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.

[0] https://www.youtube.com/watch?v=ARKbfWk4Xyw


Increasing the time to market by a factor of 3 is never worth it.


> 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.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: