Most days, I spend at least part of the day thinking My code is broken, and I don't understand why!
Today, I found
myself faced with an entirely different problem. My code is working, and I don't understand why!
To be fair, I didn't understand why it was working when I put it aside Sunday evening. I thought I might be able to figure it out with a little work, though. Now I've put some thought into it, and it only seems ever more mysterious. The intermediate steps in my computation have none of the nice properties that I think they might have, which might explain the behavior I see. At least, they don't always have those properties. When I write code to enforce those nice properties, my program stops working. I have no analysis, no intuition, no promising leads that hint at why this code should work as it does. Yet it works.
I think I have an attitude of tempered optimism. All the same, I'm suspicious. I think many good programmers I know become suspicious when code works too easily. Are there no errors, or is there insufficient scrutiny? And in this case, I'm working with a relatively simple mathematical construct. I don't want evidence that it works. I want a proof! But it does work, and I haven't figured out how to prove it yet. So I'll ponder some more, and perhaps I'll know the answer tomorrow. Or the day after. Or the day after that.
And my office mate is getting married. I don't understand that, either. I wasn't immediately that surprised when he mentioned it; after all, two of my other office mates have plans to marry as well, one a bit sooner and one a bit later. As I recall, fifteen minutes later I was telling him about Markov chains and Perron-Frobenius vectors. But then I thought about it later and was surprised all over again.
At least my recent surprises have been pleasant ones. Perhaps the good Dr. Pangloss was onto something? Perhaps Murphy was an optimist.