Sunday, December 23, 2007

Ken Thompson has an automobile which he helped design.

When I first started using unix when I got to college, when you would log out, it would print out a 'fortune'. This is the output of the famous unix program called, well, 'fortune'. They weren't really fortunes, although some of them sounded like snide fortune cookie fortunes.

Then, one day, I got this one, which I did not understand:

Ken Thompson has an automobile which he helped design. Unlike most automobiles, it has neither speedometer, nor gas gauge, nor any of the numerous idiot lights which plague the modern driver. Rather, if the driver makes any mistake, a giant "?" lights up in the center of the dashboard. "The experienced driver", he says, "will usually know what's wrong.
I didn't understand it, but I found it so compelling that I never forgot it. Who was this Ken Thompson? Surely this story wasn't literally true; but what had he done that someone was compelled to tease him in this way? Did Ken Thompson feel bad about being teased like this?

I now know that Ken Thompson was one of the creators of unix. In this fortune, the car is unix, and the giant '?' is the dreaded 'segmentation fault' error that plagues beginning unix/C programmers and which provides no useful information.

I have always felt a little bit bad for him, being teased in this way (and why does Dennis Ritchie get off so easy?). Apparently, though, Mr. Thompson and I work at the same company now, so maybe I will have a chance to comfort him.

12 comments:

James Call: Expert said...

Only tangentially related to your post, my favorite fortune cookie of all time remains "Your lucky number is 1."

Gregory Michael Travis said...

That's brilliant!

Wait, I don't get it.

Oh, wait, that's brilliant!

Unknown said...

My lucky number is i. Which means I will never be lucky. :-(

Unknown said...

I got that in a cookie from a Chinese Mathemeticians' Restaurant.

Unknown said...

Hey, what would the Scheme Car look like? I bet it would be an omnibus with little nested buses like a russian doll. And to driver is a mysterious person dressed in a yellow jumpsuit with the Y-Combinator as a logo. And everybody is rockin' out to a disco beat with the lyrics pumping out in Isaac Hayes voice: "CAR CAR CDR CAR CDR CDR CAR CAR CONS CAR..."

Gregory Michael Travis said...

After each thing it did, a Scheme car would have to tell itself to continue being a car.

That might be annoying, but the nice thing is that you don't have to drive home after going somewhere; you just save a continuation before you leave, and invoke it to go instantly home.

Unknown said...

Oh fuck yeah! You press a "continuation" button on the side of the bus and it collapses into a briefcase. After work, you put the briefcase on the ground and it expands back into a bus. The only problem is, all the context comes with it. So if it was raining before, and it's sunny now, when the continuation continues, it will be raining again. Freak!

Gregory Michael Travis said...

And if you're riding on the bus, and other riders are invoking continuations, then, since you don't perceive the time you are frozen, you look out the window and you're just warping from place to place. There are signs inside the bus saying, "Please be considerate and do not invoke continuations gratuitously."

Anonymous said...

It is a nice comparison because most of the actual system they have a error for everything. You could figure it out and they have tools to identify the problem. but in some unix bases system, users usually know how it works so they can find very easy the problem. If you want to avoid any problem Generic Viagra . This fix everything.

James Jones said...

Actually, the "?" referred to is the one and only error message that the ed editor would emit; it has nothing to do with segmentation faults.

Gregory Michael Travis said...

The "?" reminds me of ed ("the standard text editor"), but the way it's used in the fortune, it reminds me so much of the vagueness of the segmentation fault.

Phil B. said...

Went looking for the old BSD "fortune" and landed here.

Yes I believe it's about ed. The original "ed" program (Thompson had been exposed to the QED editor on the Berkeley Time Sharing System, he wrote a version for MIT's CTSS (Time Sharing System for the IBM 7090) which introduced regular expressions (may have compiled them to machine code) when he was on the Multics project, and wrote a QED for Multics in BCPL (the inspiration for the B language), which was ported to G(E)COS and used at Bell Labs on the GE/Honeywell systems there.

The PDP-7 version of ed at
https://github.com/DoctorWkt/pdp7-unix/blob/master/src/cmd/ed1.s#L769
has this:

error:
lac d1
sys write; 1f; 1
jmp advanc
1:
077012

Which writes ?\n to file descriptor 1 (stdout), and is a pretty common error routine in the PDP-7 UNIX utilities (often printing the filename first).

I don't see the first of three files for ed in the extant 2nd Edition Sources:
https://minnie.tuhs.org/cgi-bin/utree.pl?file=V2/cmd

But here's a tidbit of a V2 (PDP-11) program with the same idiom:
error:
mov $1,r0
sys write; 1f; 2
sys exit
1:
nl: <\n>