News for hackers. Stuff that matters.
Re:Experiment: Unit testing isn't enough; You need static ty... by kingkilr on Wednesday June 20, 2012 @10:23AM (#4137085)

    I'm reasonably convinced that once my program has passed the typechecker, it is logically correct
Yup, this is one of my favorite things about Haskell, that's how I know that http://bpaste.net/show/32033/ is a totally correct program.
Re:Experiment: Unit testing isn't enough; You need static ty... by dons on Wednesday June 20, 2012 @10:26AM (#4137104)
If you're hoping to catch a specification error, don't use a type like `Integer -> Integer`, which doesn't capture the specification except in a most general sense.

Just as you should write good tests, that actually test for useful properties, so you should write good types -- and get useful proofs back from the compiler as a result.

Re:Experiment: Unit testing isn't enough; You need static ty... by kingkilr on Wednesday June 20, 2012 @10:36AM (#4137158)
I wasn't trying to catch the error of "program author is a moron who doesn't know the difference between Fibonacci and factorial". Were I trying to catch that error I would have been aware of it, and then much less likely to write the bug in the first place. This is a truism that is well accepted by testing proponents: which tests you write are incredibly important, and you need to write your tests first in order to avoid a curve fitting problem (so to speak). Any non-trivial test would have shown my function to be very broken, what type would you have used to represent that so it wouldn't compile?
Re:Experiment: Unit testing isn't enough; You need static ty... by dons on Wednesday June 20, 2012 @10:53AM (#4137254)
Numerical algorithms suffer from a paucity of types. So either you enrich your numerical type hierarchy, or you prove an implementation matches a model, e.g. for fibonacci http://stackoverflow.com/a/8434107/83805
Re:Experiment: Unit testing isn't enough; You need static ty... by kingkilr on Wednesday June 20, 2012 @10:59AM (#4137288)
I don't have a response to that, other than to say, now you know why I decided to write compilers instead of pursue a graduate degree in computer science.
Re:Experiment: Unit testing isn't enough; You need static ty... by Peaker on Wednesday June 20, 2012 @12:35PM (#4137738)
If you write compilers, it would be really beneficial if you had a curiosity about the state of the art in programming languages.
Re:Experiment: Unit testing isn't enough; You need static ty... by chrisdone on Wednesday June 20, 2012 @02:01PM (#4138217)
… And lo, PHP-2 was born into the world.
Re:Experiment: Unit testing isn't enough; You need static ty... by Symmetry on Wednesday June 20, 2012 @01:41PM (#4138103)
The point about a static type system not catching all errors is well taken[1], but if a programmer has mixed up factorial and Fibonacci I would expect that their tests would reflect this as well as their code. This is more the sort of thing you should rely on code reviews to spot.

[1] Isn't the old joke in Haskell "If your program compiles it probably does something someone would find useful, but not necessarily the useful thing you want"

Re:Experiment: Unit testing isn't enough; You need static ty... by swah on Wednesday June 20, 2012 @12:13PM (#4137628)
Very elegant way to show a point...
Re:Experiment: Unit testing isn't enough; You need static ty... by drunkpotato on Wednesday June 20, 2012 @11:07AM (#4137318)
He qualified with "reasonably convinced", and you countered with an unreasonable example. That is the definition of attacking a strawman.
Re:Experiment: Unit testing isn't enough; You need static ty... by kingkilr on Wednesday June 20, 2012 @11:20AM (#4137372)
It's not unreasonable, it only seems unreasonable because of the context. I've seen several really good programmers (and overall bright people) mix the implementation of the two up.
Re:Experiment: Unit testing isn't enough; You need static ty... by chc on Wednesday June 20, 2012 @11:32AM (#4137437)
If you have the two algorithms mixed up, unit tests aren't going to save you either. Nothing will ever save you from intending to do the wrong thing.
Re:Experiment: Unit testing isn't enough; You need static ty... by dllthomas on Wednesday June 20, 2012 @12:43PM (#4137780)
If you actually use the result of the function somewhere, some tests of that component should give wrong answers.
Re:Experiment: Unit testing isn't enough; You need static ty... by afrozenator on Wednesday June 20, 2012 @01:41PM (#4138105)
I forget whose quote this is - The computer is a wonderful machine, it does what I tell it to do, not what I want it to do.

Your point taken, but that is a problem in programming language X, which has Y type system, for all permissible values of X and Y.