Tuesday, May 27, 2008

The Big Hammer

Went out for Thai with Joe, Packy, and Milosz tonight. Joe commented there was no way to figure out which process delivered a SIGTERM signal to the Linux PPTP daemon, to which I mused that "of course there is, I can do it in three lines in the kernel."

Of course what Joe meant was that there was no user friendly POSIX call for getting that information. The method I had proposed was extreme by just about any standard.

Ken Thompson is attributed with having said, "When in doubt, use brute force."

I like brute force. The big hammer can solve problems where other tools fail.

Got a problem where you don't have the source? Disassemble it.
Networking problem? Put a protocol dissector on the wire.
Intermittent hardware reset? Put a logic analyzer on the CPU's address and data bus.
Application problem? Strace it.
Driver problem? Hack the kernel.

If the usual methods of problem solving don't work, don't be afraid to go medieval on its ass.

My father, an experienced carpenter, used to say "there's a tool for every job."

He also used to say "When your only tool is a hammer, everything starts to look like a nail." I'm not saying the big hammer is always the right tool. It's just another tool you keep in your bag for the appropriate occasion.

=== begin rant ===
Maybe it's just because I'm getting older that makes me think today's Compsci graduates are wussies. They learn languages with automatic memory protection and garbage collection. Template libraries and canned data structures. ASP, C#, and Java. You ask them what to do when a program prints "Segmentation fault (core dump)" and they give you a blank stare.

Don't get me wrong, as technologies go all of the buzzwords above are "good things". But not knowing what goes on under the hood makes people crappy programmers. They can't problem-solve. As soon as the problem leaves their little world of understanding they're like a deer caught in headlights.