Archive for April 2009

Generating Source Code Contour Images

For many years, DrScheme has had a nifty feature called “Program Contour” that displays a microscopic copy of your source code along side your editor window. Each character is represented by a single pixel, which allows you to see the entire source file at a glance. This feature doesn’t seem to have gotten much attention, but recently the concept popped up on the radar when this reddit thread and this stackoverflow question pointed toward a similar image and raised the issue of the shape of good code.

I don’t claim to know what good code is shaped like, and I don’t know what impact an awareness of your code’s shape might make on its design, but I think the images are neato and I wanted to see the contour of my current project, which consists of around 34K lines of C++ code spread across 156 source and header files. The means of generating such images was not immediately obvious to me, so I developed the following technique using utilities commonly found on any Unix-like system. [Read More]