Making the easy things easy

One of the things I find most frustrating about programming is when it's not my program I want to alter. When I have some desire that's easily specified, and would be easy to do if I had control over the source that's made difficult because we don't make software that works that way. Right now, for example, I want my browser to pass all incoming HTML to some code of mine, and use the HTML it returns instead of the original. Easily said, and you can imagine that if I were the browser author this would be easy to add.

As it is, software doesn't give us the right level of transparency (so we can see what's going on, and where we'd like a hook) or the right level of hookability (so we can have our desired affect). We can do things like this, but it's made far more difficult than it ought to be.

Getting a sampled profile of an already-running program is a similar example, but one where Apple at least have made a significant step forward. Mac OS' "Activity Monitor" lets you simply select a process and click "Sample Process". A window appears asking you to wait while the sampling takes place. When it's done, the window fills with a call graph. No need to use the keyboard. No process ids. No temporary files. No pipelines. No doing it again, only this time with c++filt. Not even any need to write a script to at least reduce typing.

Activity Monitor's sampling isn't perfect; it doesn't cooperate with the Java VM to get names for JIT-compiled methods, for example, so the profile of a Java program is pretty meaningless unless your problem is in native code. But it goes a long way towards making an easy thing – profiling a C++ program – easy.

Maybe there's a healthy trend coming our way: Sun's dtrace also focuses on run-time instrumentation of production systems, because they realize that that is what's most useful and interesting. We need to give up this idea that profiling (of whatever kind) needs to be specially arranged beforehand, and there are two systems that are finally moving us away from the special-arrangements way of working.

I hope that programmers a few generations from now will have trouble believing that we had to make special arrangements (in advance!) to see what our programs were doing. Just as we find it hard to believe that people used to write programs by making holes in pieces of card and handing them to another person. And I hope that they also find it incredible that our software was not only largely unobservable; it was unadaptable too.

Any color you like, as long as it's black.

Assume the position; the computer will see you now.