argv0.net 2005/2

2005-02-22

I'm back

I've finally got PyDS set up on my new Powerbook! The OSX installer lets you connect an old laptop via FireWire at the start of the install - it almost got everything copied over from the old system, but PyDS somehow didn't make it. I also don't have that new-hard-drive feeling, since it copied over all the cruft from the old system as well.

I've also been geeking out to the SICP Lectures, which are really good, and I hereby admonish you to go watch them if you haven't already.

Also, RIP Hunter Thompson, never taking guff from these swine.

posted at 12:27:28    #    comment []    trackback []
 
2005-02-06

What Does Your Code Taste Like?

Martin Fowler introduced the concept of "code smells" in his book Refactoring, which I think is a clever way of explaining vague aesthetic notions in an intuitive, sensory way. I'm currently reading Structure and Interpretation of Computer Programs, the following two passages of which made me reflect on how I relate to code on a sensory level, a level more intangible and personal than one of classes, functions, filenames, and line numbers.
Every computer program is a model, hatched in the mind, of a real or mental process. These processes, arising from human experience and thought, are huge in number, intricate in detail, and at any time only partially understood. They are modeled to our permanent satisfaction rarely by our computer programs. Thus even though our programs are carefully handcrafted discrete collections of symbols, mosaics of interlocking functions, they continually evolve: we change them as our perception of the model deepens, enlarges, generalizes until the model ultimately attains a metastable place within still another model with which we struggle. The source of the exhilaration associated with computer programming is the continual unfolding within the mind and on the computer of mechanisms expressed as programs and the explosion of perception they generate. If art interprets our dreams, the computer executes them in the guise of programs!
...
Master software engineers have the ability to organize programs so that they can be reasonably sure that the resulting processes will perform the tasks intended. They can visualize the behavior of their systems in advance. They know how to structure programs so that unanticipated problems do not lead to catastrophic consequences, and when problems do arise, they can debug their programs. Well-designed computational systems, like well-designed automobiles or nuclear reactors, are designed in a modular manner, so that the parts can be constructed, replaced, and debugged separately.

After some reflection, I realized that below the surface, I have a mostly auditory model of program execution. For example, a script that processes logfiles has a simple, repetitive rhythm - one that probably varies with the nature of the process and it's input data. Algorithmic code I "hear" similarly, except the rhythm is more complex and accentuated, and varies according to the nature of the process - Dijkstra sounds different than a binary search.

Visualization is the most common way of expressing program execution as sensory data, like these call graphs of recursion and generator expressions in Python code:

But visualization is, in my opinion, a relatively high-level abstraction, and not the most personal, at least not for me. They say smell is the most emotionally evocative and memory-stimulating of the senses, and after a few weeks on vacation, I find myself forgetting what family members and close friends look like. Not completely, but the mental picture isn't as sharp, even after only a short time away.

I mentioned the sound of my code to my cube-neighbor Greg, half-expecting him to tell me to lay off the LSD. He didn't think I was crazy, and related his internal model to me, one that was more visual - "textures" was the main abstraction he seemed to have.

I think a large part of the learning curve involved with learning new codebases, even after reading the API docs, knowing the module layout, maybe even reading some of the source, is the lack of a low level sensory model of how that code runs. I know I have one of these for Twisted (and asynchronous programming in general), and it differs from that of threaded code, but I'm afraid I lack the language to describe it, because its components are so integral to all the abstractions I build, including language.

Expressible or not, I think exploring and understanding one's own low-level models of how their programs behave is valuable. Does anyone have other interesting models? Can any chefs out there taste their code? Or should I lay off the LSD :) ?

posted at 00:09:20    #    comment []    trackback []
 
2005-02-05

The Financial Consequences of Love and Gravity

I killed another Powerbook. Rather, my wife did. While stumbling over some books I'd left on the living room floor, she was forced to decide between shattering one of two things with her downward-moving foot: my Powerbook's LCD (left on the floor by me, of course), or my cat's neck. She chose the LCD of course, because she loves our little kitty, but its quite unfortunate nonetheless :(

The good news is, a new laptop is on the way (at a FedEx facility in Shanghai as I write this, actually), and our kitty's spine is in one piece:

posted at 22:44:00    #    comment []    trackback []
February
MoTuWeThFrSaSu
  1 2 3 4 5 6
7 8 910111213
14151617181920
21222324252627
28      
Jan Mar

a python programming journal by Andrew R. Gross

XML-Image Letterimage

© 2005, Andrew R. Gross