I'd gone over the easy stuff. Nine times out of ten, or even some higher, less often used percentage, the reason code doesn't work is some stupid thing. I know you're not all programmers, so I'll try to explain. It would be like if your email wouldn't send if you had a typo, or if it got delivered to the wrong person if your grammar wasn't quite right. Is that a good analogy for the non-programmers among you? I don't know. I don't remember how to think like a regular person.
If it wasn't something easy and obvious, it was something mysterious. My code was calling other people's code, and there was some secret in that other code that was making my code not work. Like if you were forwarding an email with a spelling mistake in it, and that mistake caused your email to send itself 300 times. I'm just confusing everybody with these bad analogies here.
In college, we had a class where we spent the entire semester on one program. Rumors of this class scared the pants off the underclassmen. Up until that point, we wrote programs in two week cycles. They did things like draw geometric shapes. The program would ask you for a number and a letter, and then draw you a square. For extra credit, you could program it to give you the option of drawing a triangle.
# shapes.exe
Please enter a letter: b
Please enter a number: 3
Would you like a square (s) or a triangle (t)? w
Bad Input. Would you like a square (s) or a triangle (t)? t
b
bb
bbb
#
Does that look like extra credit work to you?
To go from that to writing an interpreter for the PDP-11, well, it was a jump. Not as big of a jump as going from writing small programs from scratch in college to maintaining someone else's decade-old code in the real world, but a jump nonetheless. Some of you don't know what a PDP-11 is, and that's okay, we didn't either.
We were given weekly assignments, each one adding new features to our program. My partner and I were doing great. We'd kept up with the assignment and it spit out the correct response when we fed it the test data. But during the last week, the very last assignment, we hit a wall, a heuristic fence post. The last feature did not give the right answer. It was an additional dozen lines of code. We looked at it, messed with it, played with it. It would not work. We despaired. We had run into a truly mysterious bug, the first of many in my life.
I was thinking of that project this afternoon, when a dozen lines of code were giving me fits. So I was trying things. I was changing how the code did what it did, hoping that I would somehow circumvent the mysteriousness. The regular people among you are probably a little frightened at the guesswork in it. If something doesn't work, shouldn't I be able to tell why? Do people really go about taking shots in the dark?
You poor, poor people. Your computer has bugs, every piece of software you have ever used has bugs. There will always be bugs. It's not that the computer is not totally logical, it's that sometimes the picture is bigger than we can see. There is logic, but heck if we can find it sometimes. It is an odd thing, this modern faith.
I knew my code wasn't working because I got emails that told me so. Isn't that nice? Rather than my code just spitting out the wrong thing or crashing the application, an outside force sent me reminders that I still hadn't found the answer. My code was sending a message to some other computer using different code. The other computer's code sent me emails that said "FAILURE" or "ERROR" or "GEEZ, YOU SUCK." It was expecting the messages from my code to look a certain way and say a certain thing, and my code stubbornly refused to be accommodating. I had a failure email from 1:59 PM, 2:03 PM, 2:04 PM, and 2:07 PM. Each one represented a new try. The first one I changed this line, the second one I changed another.
The email I received at 2:25 PM said "Holy Lobster, Batman! It works!"
I did not write that email message. The system administrator did. He's as weird as any techy person, but the whole lobster thing, well, it's my fault. During some other semester of my college programming days, I had to write test data for a program. I'm not the kind of girl who can just use "Mary Smith 123 Main Street." I like to inject some creativity into my programs, because otherwise the right side of my brain cries at night. This way I can convince myself that it wasn't a mistake to become a well-paid soulless code monkey instead of a pure and starving writer. And so I used "Lobster Ravioli" somewhere in my data, probably because that had been the special we'd been serving at the restaurant that week. The words "lobster" and "ravioli" are inherently funny, like "underpants" or "macadamia". And this week, when I had to come up with some test data for my code to send to the other computer's code, Lobster Ravioli came through for me again.
I had not anticipated the system administrator to a.) see it, and b.) mention it every time he saw me.
Regardless of the silly way that the 2:25 PM email said it, it did say that my code now worked. It was sending the right message. The trouble was, I didn't remember what I did. If it's upsetting to think that sometimes the computer mysteriously doesn't work, is it even scarier to think that sometimes it mysteriously does? And at that point, the programmer slowly and quietly steps away from the keyboard, afraid to touch anything lest she disrupt whatever cosmic force fixed the problem?
Back to that semester-long project, that almost correct PDP-11 interpreter. We gave up on fixing the bug. Even as young and naive students, we were prepared to accept that sometimes the computer, in all its infinite wisdom, works in mysterious ways. To make up for the bug, I was going through the working code and adding comments. I never used comments in college except when the program was broken. It was my way of sucking up. I was also doing a little clean-up. Like when you read back through your email and add a couple of carriage returns for readability.
I finished up and ran the program with all the test data again to make sure I hadn't broken some new thing. And suddenly, it worked. I had changed some little thing in a completely unrelated piece of code that we had written months ago, which had never given us any problems. And suddenly the thing that hadn't worked before did. Holy Lobster, Batman.
No comments:
Post a Comment