8

The phrase "sanity check" comes up often in programming, e.g.

It's a good sanity check before attempting to decrypt the key.

Usually, its context is one in which a commonly assumed state (e.g. no memory corruption) is being tested, explicitly. For a long time, I interpreted "sanity" as the state opposed to "insanity", e.g.

It's a good check to make sure we don't lose our minds before attempting to decrypt the key.

Because of the many instances I'd spent hours, or days, debugging a mysterious bug, only to find the cause to be some uncommon state in the environment or data, this interpretation made sense to me; a sanity check would have saved my sanity.

But then I realized that "sanity" had a more canonical meaning: cleanness, e.g.

It's a good check for cleanness before attempting to decrypt the key.

Which is the interpretation meant by the phrase, "sanity check"?

7
  • 1
    To make a sanity check is just a quirky idiomatic way of saying make sure what we're doing (or what we're looking at) isn't completely insane/ridiculous/obviously stupid. It's not a direct reference to the sanity of the speaker (or his audience). Dec 20, 2012 at 19:05
  • @FumbleFingers - Ah, yes, that's a much better wording for the interpretation I held for a long time. I'm still not convinced though. Could "sanity" in that phrase actually have meant "cleanness" when it was first used, but due to the word "sanity" being more popularly recognized as the opposite of "insanity", adopted a new meaning? Dec 20, 2012 at 19:12
  • 2
    It means a check that we or the situation are not insane. For example an "assert" is a form of sanity check.
    – MetaEd
    Dec 20, 2012 at 19:16
  • @acheong87: I personally wouldn't use "sanity check" to refer to basic validation of input parameter formats, for example. But if it was in the context of, say, an input form for a car insurance quote, asking for the applicant's Date of Birth, I might call it a "sanity check" to make sure the value input didn't imply the applicant was over 120 years old! Dec 20, 2012 at 19:17
  • 1
    When you get a working definition of sanity, please send it to the U.S. Congress. They're the ones who could benefit most.
    – Robusto
    Dec 20, 2012 at 19:36

1 Answer 1

7

I refer you to dictionary.com, where it states (eventually):

Synonyms

  1. reason, rationality, sensibleness, reasonableness.

(emphasis added.)

A sanity check is simply a test to confirm that we are asking, or being asked for, something that is within some defined bounds of reasonableness.

3
  • Ah, I see. It seems the word "sanity" doesn't have anything to do with cleanness or pureness. I had always believed it did, thinking it to be a root of the word "sanitation". But it appears that that was exactly the culprit, looking at the etymology of "sanitation". Dec 20, 2012 at 19:23
  • @acheong87 But it does. The Latin sanus, which is the distant root of both words, means healthy.
    – Andrew Leach
    Dec 20, 2012 at 19:49
  • @AndrewLeach - Yes, but I guess what I meant is that I inferred the meaning of "sanity" from "sanitation", which I incorrectly believed to mean "cleanliness" to begin with (as opposed to something to do with health). Had I had my premises straight and understood that sanus means healthy, as you point out, I probably wouldn't have had this confusion. Dec 20, 2012 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.