4 ms·
3% is the right order of magnitude and if it is +10% more than that that wouldn't make any difference. Static typing would still be twice as bad as dynamic typi
by ReflectedImage 4y ago
3% is the right order of magnitude and if it is +10% more than that that wouldn't make any difference. Static typing would still be twice as bad as dynamic typing when it comes to code correctness.
"What if you already know the majority of your bugs, as logged today, could be prevented by a type checker?"
You would be a very bad programmer, since the vast majority of bugs are logic bugs.
"why does C do static typing" Code performance. It needs them to effective map types to registers avaliable on the machine it's been compiled for.
Rust lifetimes are about getting C like performance without the bugs introduced by using the techniques required for C like performance. You could remove Rust lifetimes and get all the same safety, it's just the programs would run slower due to garbage collection.
"So then TypeScript. Let's assume " TypeScript is an obvious bad example since JavaScript is a very bad language since it was hacked together by browser makers over several decades. You could make a dynamic typed equivalent of TypeScript and it would have the same advantages.
"The argument for static type checking is strong" It's incredibily weak it prevents a class of bugs that only occur very rarely in dynamically typed languages (3%). By both increasing your development time by 2.5x and increasing the total number of bugs in your program by 2.5x.
You wanting to believe in static typing doesn't stop it sucking in the context of scripting languages.
- jchw 4y ago> You would be a very bad programmer, since the vast majority of bugs are logic bugs. I don't work alone. Most of the time, I work on projects that predate my involvement, and are old enough to have accumulated cruft. But I think I found the disconnect. This right here is the key: > since the vast majority of bugs are logic bugs You might think that there is no way a type checker could prevent a logic bug. You're wrong. It is clear to me now that when you say 3%, you are talking not about the type of bugs that static type checkers are capable of preventing, but only errors that are explicitly related to types. Because if you model your code with types as you go, types do prevent all kinds of logic errors. When you write code with strong typing, it can prevent impossible state machine transitions, ensure that you handle all cases of a set of possibilities, ensure that you follow API contract obligations, and more. Exactly how much a given type system is capable of inferring and decoding varies. TypeScript is definitely the state of the art for type erasure systems built on script languages, and what it is capable of encoding is pretty impressive. Maybe, maybe, the amount of bugs that you can attribute to typing issues is 3% if we're only regarding Python TypeErrors; but, a proper type checker goes far beyond that.
- ReflectedImage 4y ago"a proper type checker goes far beyond that" But if it can't catch 60% of all errors and it can't. Then it's worse than dynamic typing. This isn't complicated. If you are excluding performance, then static typing is inferior to dynamic typing. It's that simple. No ifs, no buts. I do write statically typed code but that's for performance critical code. Since I've got good experience of both, I understand the differences very well. I assure you that using static typing in a scripting language like Python is a mindnumbingly stupid thing to do.