5 ms·
If you rely on your compiler to tell you that your code is correct, there are whole classes of bugs that are waiting to surprise you in production. I think tha
by DougWebb 12y ago
If you rely on your compiler to tell you that your code is correct, there are whole classes of bugs that are waiting to surprise you in production.
I think that many years of developing large applications in Perl were really good for me. Perl is compiled when you run it, so you get the basic-syntax check that you get with other languages. But it's also very lenient, so you learn through experience to get your logic right, test return values, and do all of the things that help make sure that a program which executes is executing correctly.
- brianwawok 12y agoThere is a difference from RELY on compile to catch 100% of bugs, vs having an awesome type system that can take whole CLASSES of bugs and make them impossible to get past a compile. Is a statically typed language more likely than a dynamic language to work correctly in production, if both have 0 tests? Yes. Is either ideal? No. Can both be improved by adding a few tests? Yes.
- DougWebb 12y agoI agree with you on all points, but the parent sounded like he was relying on the compile-time checks to determine correctness. I was making the point that that is a bad idea.
- pdonis 12y ago> Is a statically typed language more likely than a dynamic language to work correctly in production, if both have 0 tests? Yes. I'm not sure I agree. "Work correctly" does not just mean "compile correctly". I would want to see a lot of evidence to back up any assertion that programs written in statically typed languages are less likely to contain logic errors that compile and run just fine but don't do what the programmer (or his client) actually wanted. I agree that neither is ideal and that adding testing can improve any code.
- dragonwriter 12y ago> I would want to see a lot of evidence to back up any assertion that programs written in statically typed languages are less likely to contain logic errors that compile and run just fine but don't do what the programmer (or his client) actually wanted. As certain assertions related to logic can be encoded into static types (especially in a language with a type system more like Haskell's than, say, Go's), while static typing can't eliminate all logic errors, it can reduce the probability of logic errors escaping detection in the absence of testing, since compiling a statically typed program is, in effect, a form of testing (limited to those assertions about behavior which can be encoded into the type system.)
- pdonis 12y ago> compiling a statically typed program is, in effect, a form of testing (limited to those assertions about behavior which can be encoded into the type system.) Fair point. (Especially if, as you say, you are using a language with a type system like Haskell's, which to me is more like a program analysis engine than just a type system.)