Don't you hate it when you write a whole bunch of code without compiling or running it at intermediate steps, usually because it's a big thing that really doesn't do anything unless it's complete? For example, an involved recursive algorithm, where unless all the parts are integrated correctly, and data is returned correctly at each invocation, you don't get anything at the end
So now I'm about to hit compile and watch everything blow up at me, and I'm about to go through that inevitable frustration where after a while you think it's working, and then you find yet another bug.
Paul Graham, however, thinks this is the most natural way to program. He doesn't mind at all:
For example, I was taught in college that one ought to figure out a program completely on paper before even going near a computer. I found that I did not program this way. I found that I liked to program sitting in front of a computer, not a piece of paper. Worse still, instead of patiently writing out a complete program and assuring myself it was correct, I tended to just spew out code that was hopelessly broken, and gradually beat it into shape. Debugging, I was taught, was a kind of final pass where you caught typos and oversights. The way I worked, it seemed like programming consisted of debugging.
For a long time I felt bad about this, just as I once felt bad that I didn't hold my pencil the way they taught me to in elementary school. If I had only looked over at the other makers, the painters or the architects, I would have realized that there was a name for what I was doing: sketching. As far as I can tell, the way they taught me to program in college was all wrong. You should figure out programs as you're writing them, just as writers and painters and architects do.
I like debugging: it's the one time that hacking is as straightforward as people think it is. You have a totally constrained problem, and all you have to do is solve it. Your program is supposed to do x. Instead it does y. Where does it go wrong? You know you're going to win in the end. It's as relaxing as painting a wall.
I really like his philosophy... "you know you're going to win", therefore it should be relaxing.
Programming alá Trial-and-Error. Great.
Don`t get me wrong - i DO know that one can`t plan EVERYTHING beforehand. But to me that comment sounded like .... "I´ll try something - and i know it will be working". And it WILL work mostly.
But I`d rather stick to the paradigm of "Think first" .....