43 points · by nickmain · 13y ago · 63 comments
This really is a gross misuse of Gödel's theorem. Taken to it's logical end his argument is that any field that has logical foundations should value human judgement over rigor and proof because of incompleteness. Should we just throw out all of mathematics as well because there are true but unprovable theorems?
Mathematical proofs are explicitly logical statements, if they aren't based in logic they aren't proofs by definition. Mathematical intuition is what leads us to ideas but it's only within the framework of formal reasoning that we "know" anything within mathematics. Poincare said it nicely:
"It is by logic we prove, it is by intuition that we invent."
Vastly more type errors (i.e., conditions which cause the program not to hold the property checked by the type system) are caused by programmer error than by deliberate design; a strong, static type system, checked at compile time, helps ensure that a whole class of relatively weak but trivially easy to write bugs do not find their way into the finished program. The programmer hours saved in not having to worry that some little-exercised code path will attempt to add an integer to a string, nor to write exhaustive tests covering every possible code path to make sure no integers get added to strings, adds up significantly over the program's lifecycle, from initial development through maintenance and support.
Be kind to your programmers. Use a statically-typed language.
I question whether that is a "good" program.
But static typing would also stop the compile in situations where mixing types was not foolish. Static typing says you must give a definite type to every variable and every expression; but that's not always the best way to write your program. (To take a simple example from Python, there are plenty of cases where you want a function to return either a string, say, or None, depending on whether it is able to find a string meeting some set of criteria, and you can't use the empty string as your "not found" value because empty strings are semantically significant for your application.) So static typing unnecessarily restricts the kinds of code you can write. That seems to me to be the article's basic point.
1. Add a comment around the whole block. This may not always work, as comments within the block may need to be removed.
2. Add string delimiters before and after the block, making the block an in-place string literal. This can be broken by strings within the block.
3. Use a goto statement to skip the block. This is a pretty good method but you have to worry about the label getting moved, and fellow developers laughing at you for using goto.
4. Wrap the block with a big if (false) { }. This is the most bullet proof method, but it violates your goodness criteria.
Edited addition to reduce the snarkiness a bit: if I see a block of dead code like that left in a file, regardless of which way it's been killed, I'm going to consider that bad unless there's a very clear comment explaining why this isn't needed anymore but was worth leaving in the code instead of fully deleting it. But if that comment's there, and the reason makes sense, it's still breaking the "rule" but becomes an example of knowing when to break the rule.
Large amounts (I regularly see 500+ lines in a single file) of commented out code is a huge smell and it would take an outstanding justification to get me to not delete it.
-- Removed Foo handling in revision ... because of ...
That should be rare, though.For temporary disabling, I tend to do:
const disableFooForDebugging = true
if( disableFooForDebugging)
That makes it easier to recognize and correct accidental checkins.The premise is that for real world inputs some code may never be used, and so it's an advantage for late-checked types that you can have wrong code that will never cause any observed bug. I'd rather "waste" my time deleting nonsense code after it fails an early type-check. Less code = better reading/maintenance/extension.
Better to focus on the real advantages of single-type languages (usually, terser programs, although type inference can make some haskell/ML programs apparently type-less).
Maybe the compiler can just complain about the user. "Seriously, this guy first gets me to make this integer, and that's cool, but then he starts to use it like it was a float, so you know, I gotta go and rearrange ALL the bits. Then you know what he does, he goes and takes another integer and tries to math them together. Screw that guy. But you want to know the kicker? After all of this, he casts it back to an int and then tries to append a string. Seriously. Make up your mind. I need a beer. What do you think I am, Javascript?"
Maybe the compiler just gets angry. "You know what? First you claim it's this structure, then you treat it like that structure. Whatever, I say it's crap. I'm deleting it. Write it again, and make sense this time."
I prefer my computers less human.
I thought the logic was: if you reject all bad programs and some good programs, only good programs remain, is it not?
That being said, perhaps it would have been a better article if the author presented some arguments of "bad" programs that pass the type system, as type systems are no silver bullet and do not guarantee rejection of all bad programs.
Doesn't this definition encompass dynamically typed languages as well? e.g. P is syntactic validity?
Ot, one might go the Qi/Shen route...
I think another good example of a optionally static typed language would be Julia, where you can add types, and if you add them, the compiler will try to leverage that information to optimize your code [2].
I've used dynamic and static languages mixed for most of my life (Javascript, Python, PHP back in the early 2000's VS. C and Objective-C). Recently I started working with Scala, which has much stricter typing than, say, Objective-C, and I have to admit that after a bit of early helplessness in the beginning, it feels strangely liberating that, once the code compiles, the program is solid. Successful compilation brings with it a sort of satisfaction.
[1] http://docs.racket-lang.org/ts-guide/ [2] http://docs.julialang.org/en/release-0.1-0/manual/types/
Is this wrong?
"true but not provable" is easy.
What is an example of a statement that is "provable but not true"?
So you need to assume two contradictory things are true, somewhere deep down in your logical system. As a trivial example, assume that both the following are true:
1. I am a robot. 2. I am not a robot.
And our false statement which we are going to prove is:
Pizza is made of fear.
We know that the following proposition is true:
I am a robot OR pizza is made of fear
Because we know that I am not a robot, the first term in the above must be false, and so the second term must be true. Therefore, pizza is made of fear.
That's really more an example of the principle of explosion, but the above is a tiny logical system which contains statements that are provable, but not true.
In practice, we tend to use logical systems which can't prove all true statements, but don't let you prove false ones. Much more useful, really.
Poor example. In Java, number + string means "convert the number to a decimal string then concatenate", and it can be invoked unintentionally.
http://ghc.haskell.org/trac/ghc/wiki/DeferErrorsToRuntime
http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/defer...
This is inconsistent code to being with, though. You can't guarantee it "never" reaches the first branch, as much as you can't guarantee there aren't bugs in the conversion function, or on the underlying interpreter, or that machine details wouldn't make a big enough number wrap around and return negative. All in all, an inconsistent code branch hanging around is a bug even if it compiles.
This is more an evidence that "if" is evil rather than an argument about typing, really.
I know that the strengths of racket lie elsewhere, but I wish the performance would be better (at least comparable with sbcl) ;)
As for dynamic vs static typing - I don't care much about human rights, so I prefer static typing :D
Dynamic typing (and laziness) is good when you don't have to care about memory footprint nor performance of code you write e.g. when you're prototyping something.