3 ms·
>Static typing doesn't ensure correctness for languages like C++ and Java. Types provide a pretty high amount of proof towards correctness, in theory and in pr
by rtpg 13y ago
>Static typing doesn't ensure correctness for languages like C++ and Java.
Types provide a pretty high amount of proof towards correctness, in theory and in practice.
In my experiences working with Haskell (and its type-system), I've found the amount of runtime bugs I hit to be almost non-existent, because usually the type system catches all my stupidity beforehand. It's weird, because the type of runtime bugs I get in other languages (like Python) are rarely type-related issues, but for some reason it seems to help a lot.
The arguments for dynamic typing are very less convincing when you start getting into systems with very expressive type systems such as Haskell.
There are so few use-cases of un-type-able code out there that it really shouldn't be as demanding, but unfortunately people have conflated typing with verbosity and uselessness, instead of things that can work extremely well as proofs of some amount of correctness.
- _random_ 13y agoThe ideal: "if it compiles it is guaranteed to work as you intended when writing it".
- freyrs3 13y agoReality: "Type systems don't keep you from writing wrong logic, they only forbid you to write inconsistent logic."
- laureny 13y agoIf such a language existed, you wouldn't need to write any function body, all the code you need would be encoded in types. However, even the most advanced Turing complete type systems make for terrible sources, so it's probably not an ideal we should strive for.
- Dewie 13y agoThe quote: > Why didn't you have tests that caught the syntax errors? Static typing doesn't ensure correctness for languages like C++ and Java. It seems like they is saying: "you have to write more tests, yes, but you have to write tests, anyway!" So if I have to write 20 tests in one language, and 200 in another, the difference in effort is negligible because I need to write tests anyway? So if you can express something in 10 times less code in one language compared to another, it doesn't really matter since "you would have to write some code, anyway!". I really don't get this 'you were going to write tests anyway [says who?], so you might as well write it for any possible unintended null-value, value-was-string-but-should-have-been-char, too long argument tuple in function call....."