News for hackers. Stuff that matters.
Re:Are you one of the 10% of programmers who can write a bin... by abstractbill on Monday April 19, 2010 @03:51PM (#1277654)
NO TESTING until after you’ve decided your program is correct.

Why? What is there to be gained by asking programmers to abide by such an unnatural constraint? I would never "decide my program is correct" without having tested at least bits and pieces of it in the REPL.

Re:Are you one of the 10% of programmers who can write a bin... by LiveTheDream on Monday April 19, 2010 @04:08PM (#1277694)
Because every programmer's gut reaction to binary search is "that's easy!". The no testing rule says "orly? then show me"
Re:Are you one of the 10% of programmers who can write a bin... by abstractbill on Monday April 19, 2010 @04:36PM (#1277778)
every programmer's gut reaction to binary search is "that's easy!"

Perhaps I'm not a programmer then. Or I'm a strange one I guess.

I tend to approach every programming problem assuming the worst: This will be much harder than it seems. There will be corner-cases. I will miss some of them and do the wrong thing for other ones. I should try to enumerate every weird condition I can think of, and then throw random inputs at things to catch the stuff I missed.

Re:Are you one of the 10% of programmers who can write a bin... by sukuriant on Monday April 19, 2010 @11:13PM (#1278519)
Sounds like I'm not a programmer, either. Working on the Programming Team for my school for many years taught me to consider edge-cases.

And personally, there's quite frequently SOMETHING I forget when writing a binary search, and it usually ends in it infinite looping -- so, I often have to go find my stupid mistake.

Re:Are you one of the 10% of programmers who can write a bin... by Dove on Tuesday April 20, 2010 @12:39AM (#1278649)
Binary search is easy. Unless you're going to force me to do it with a Turing machine, and all names and notes must be in pig latin, and I have to do it all while gargling lemonade.

But, then, that wouldn't exactly the fault of binary search, would it?

There's a reason incremental testing is normal practice. It makes you smarter.

Re:Are you one of the 10% of programmers who can write a bin... by stingraycharles on Monday April 19, 2010 @03:53PM (#1277659)
Because it forces one to think things through instead of using trial and error.
Re:Are you one of the 10% of programmers who can write a bin... by derwiki on Monday April 19, 2010 @04:04PM (#1277685)
Isn't one of the advantages to programming over other disciplines that we can create unit tests that define "success" and iterate quickly until we get there?
Re:Are you one of the 10% of programmers who can write a bin... by DLarsen on Monday April 19, 2010 @04:14PM (#1277719)
Unit tests are code too. What ensures the correctness of the tests themselves?

My point is simply that you can't simply defer to testing as a cop out to avoid claiming confidence in the correctness of some portion of code. There has to be some amount of code that a dev can pretty well validate simply by inspection. (I'm not saying don't test.)

Re:Are you one of the 10% of programmers who can write a bin... by abstractbill on Monday April 19, 2010 @04:29PM (#1277760)
You say that as if it's a given you can only do one or the other.

FWIW, I'm a pure mathematician by training - not exactly a shortage of experience in thinking things through. But I would have very low confidence in any code I had just written down, instead of building it iteratively, using a REPL.

Re:Are you one of the 10% of programmers who can write a bin... by DLarsen on Monday April 19, 2010 @04:02PM (#1277681)
Maybe the wording used was a little unnatural.

None of us write code and have no clue whether it's correct or not. We should have a certain degree of confidence.

In the example given, I think it would be more realistic to ask devs to write the function (without testing) and then note how confident you are in its correctness. I have no problem with someone who is pretty sure they have bugs and can discover and fix them. But if someone is confident they have it right and they're dead wrong... now we have a problem.

Re:Are you one of the 10% of programmers who can write a bin... by FutureNerd on Tuesday April 20, 2010 @02:25AM (#1278798)
No, there's a point to doing the unnatural thing of, "Keep working on it till you're sure you got it right."
Re:Are you one of the 10% of programmers who can write a bin... by decode on Monday April 19, 2010 @04:36PM (#1277777)
Because trying it and failing you teaches you not to do that. Or, more generally, 90% of programmers failing the task tells us programmers are bad at programming without testing and we need to have solid testing in place when we code.
Re:Are you one of the 10% of programmers who can write a bin... by jpr on Wednesday April 21, 2010 @04:38AM (#1281667)
You do realize that testing can only show the existence of bugs, not their absence or the correctness of the program?