04 Apr 2009
Need to know

Blankets

When I was a kid, I’d help my mom with the occasional defrosting and cleanup of the deep freezer in the utility room. To keep the contents from thawing out during the process, we’d pile everything into tubs and cover them with quilts. Early on, I understood the thermal characteristics of quilts. Apparently not everyone does….

So what really happens when you put cold stuff under a blanket? See “A blanket and cold stuff” at Dot Physics for discussion. Hat tip to “Cans in a Blanket“, which mentions the old joke about how smart a thermos is (it “knows” when to keep hot stuff hot and cold stuff cold) and provides the summary “But the misconception — that blankets heat things up, rather than acting as a barrier to heat transfer, is what is pointed out in this example.”

Unknown Unknowns

Rumsfeld is (in)famous for his 2002 statement

There are known knowns. These are things we know that we know.
There are known unknowns. That is to say, there are things that we know we don’t know.
But there are also unknown unknowns. There are things we don’t know we don’t know.

(He left out the “unknown knowns”: things you don’t consciously realize you know, or reality that you pathologically deny. Anyway, fodder for another day.)

I like to know how and why things work, so I’m particularly annoyed by statements like

I don’t need to know how it works, just tell me how to use it.

You can get by with that world view often enough to be successful with it, for some meaning of “successful”. Of course you’re subject to the frustration of Cargo Cult Programming (or the equivalent in your field), or the daily bewilderment of things appearing to be just a little off from expectations, magical in behavior, or affected by some capricious deity who likes a good prank now and then.

You have to turn “unknown unknowns” into “known unknowns”. You can’t address your lack of knowledge until you become aware of it.

The Compiler Is Broken

When I worked at a college, I would inevitably get the frantic or outraged report that some compiler or interpreter was fundamentally broken. In essence, the complainant would point out that (language equivalent)

  1. for (x = 0.0; x != 100.0; x += .1)

would go into an infinite loop. The real problem was that new users either believed that computers understood and used ideal mathematics, or had come from “mainframe” backgrounds where all math was done with decimal data types rather than defaulting to low-precision floating point. Sorry, but adding 0.1 (which is only approximated in binary) 1000 times does *not* equal 100 — With gcc, it’s off about 0.001.

Should I Believe In Magic?

One of the most frustrating complaints I run across from time to time is due to shell expansion. On unix-derived systems, the shell is responsible for expanding wildcards (or globs) — bash is especially rich with additions such as brace-expansion — so only specialized programs worry about dealing with them directly. Some users who’ve only ever been exposed to non-expanding shells from other OSs just don’t seem to get it. Even after it’s explained to them, they still secretly think something is broken.

Particulary frustrating for them (and for me, because I want the user to be successful, not blame the OS for being “broken”) are commands like locate, which can use globs but won’t ever see one unless they’re quoted. To add icing to the cake, locate uses a database rather than the live file system.

Someone enters “locate *foo*” at the shell prompt and they get zero files listed, only “their” matching files, none of their files, or a huge list of files from across the system — and the results vary from day to day. They get angry that the command doesn’t “work”, or a queasy feeling that there’s incomprehensible deep magic involved.

Here’s a demonstration and a hint: test your command line with echo. Let’s say you have only three files in your current directly:

  1. $ ls -1
  2. itsafoobar.txt
  3. justafoobear.txt
  4. keepitsimple.txt

Now use the echo command to test glob expansion:

  1. $ echo *foo*
  2. itsafoobar.txt justafoobear.txt
  3. $ echo *tafoo*
  4. justafoobear.txt
  5. $ echo *nothere*
  6. *nothere*

You’ll notice that only in the third example, where there was no matching file, will the glob be passed on to the command itself. If you replaced “echo” with “locate“, in the first two examples only file names (more correctly, paths) containing those exact strings would be found. Only in the third case would locate actually use a glob.

The other gotcha? Use a literal string:

  1. $ locate keepitsimple
  2. $

Not found? Well, the database hasn’t been updated since the file was created. Typically, the update occurs in the wee hours of the morning.

What To Do

Whenever things don’t behave as you expect, perhaps you should meditate on the classic “that doesn’t mean what you think it means”, rather than blaming something you don’t even understand.


Duty Calls (xkcd)

Category: Life-Society
Tags: , , , ,
(comments closed) | (trackbacks closed) | Permalink | Subscribe to comments |

One Comment


  1.  Shawn Constance (2 comments)
    Posted 2009-04-08 at 07:41:37 | Permalink

    I like the comment on “The Compiler is Broken.” This principle has to be true in every trade. I have to constantly remind myself that, when I don’t get the exepcted results, I must not understand the governing principles. Once I drop the assumptions, the solution is usually right at hand.

Site last updated 2015-01-12 @ 13:31:07; This content last updated 2009-04-04 @ 13:59:32