A computational person’s nightmare

Anybody who writes code for her research knows about the scary feeling of a bug being there in the code; may be the exciting new results are all but an artifact of the code; and, what is worse, may be the bug in the code is a silly, elementary mistake.

Of course, I have had my share of such nightmares too — not just the feeling, but at least twice, did notice mistakes themselves. But, fortunately for me, (a) I noticed them myself; and, (b) the mistakes were minor.

All this has taught me that while it is almost impossible to avoid bugs in codes, there are several ways in which one can pick them up: (i) Have some sharp eyed colleagues go over your results (and, if you are as lucky as me, they might even be willing to go over your code) and spot any unphysical results; (ii) Explain you code to a human; this is almost a fail-safe way of spotting mistakes; I think in the coding community this is closer to the pair-programming concept; (iii) Keep benchmarking your code and keep coming up with newer and newer tests; while bechmarking, I have also found that it is important that you match numbers within the accuracy of your calculations; numbers not matching at the fourth or fifth decimal place, sometimes have led me to identify the bugs in the code. (iv) Make your code open source and share with as many users as possible. Even if a few of those users turn out to be developers, they will notice errors, if any. (v) If possible, find another colleague who will implement the same code, and results matching from two people increases the confidence in the code enormously; as my advisor used to say the probability of two people making the same error goes down multiplicatively.

All the above thoughts are triggered by this link list from Abi, and especially this report.

Of course, if you are any lucky, you will also get to experience, once in a while, the following feeling during your research career:

“I almost didn’t believe my eyes when I saw just the basic spreadsheet error,” said Herndon, 28. “I was like, am I just looking at this wrong? There has to be some other explanation. So I asked my girlfriend, ‘Am I seeing this wrong?'”

I will save my thoughts on this for another post (and also my thoughts on the ease with which you can mess up things while using excel: I remember the terrible mess I made while grading for the first time for a large class using excel spreadsheet). In the meanwhile, I recommend that you follow all the links in Abi’s post.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: