Duff's Device by Tom Duff
Described as "the most dramatic use of fall-through yet seen in C", Duff's device is a remarkable algorithm that somehow marries two C structures in a surprising and efficient way. The result is both ugly and beautiful; disgusting and elegant. The purpose of Duff's device is to transform data into an output stream, although it's more commonly used to confuse students and experienced [...]
[ go to project page ]
Duff's Device

Duff's Device is an example of an algorithm that can be appreciated from a purely formalist perspective. Like most algorithms, it turns input into output. But in the case of Duff's Device, it's the way it does what comes in between that's of interest.

The process is complicated to understand even for C programmers; it's kind of like trying to figure out an M.C. Escher image. But, imagine that data is water flowing into a bottle. Now imagine that in Duff's Device, the bottle is more like a Klein Bottle in concept: somehow the bottle feeds back into itself in a way that's hard to grasp mentally - yet it's irrefutably happening. Now imagine that the bottle isn't even as round and even as a Klein Bottle, but that this looping back onto itself happens in a weirdly crooked, comical way. (Or, even more comical than actual Klein Bottles, for those who find those amusing.)

If Duff's Device existed only on paper it would be an amusing fantasy. The fact that it actually works - and does something useful - makes it even more interesting. It points out that programming, even for utilitarian ends, is a creative practice that has aesthetics of its own. In some cases, these algorithmic aesthetics integrate with the output - for example, "real world" processes can be metaphorically expressed through algorithms. But in the case of Duff's Device, the aesthetics of the algorithm are of interest without reference to the output - an example of how programming and algorithms can have their own abstract aesthetics.

by Amy Alexander, posted 04 May 2003

newcomers, sign up here.




forgot your password?
latest projects
Light Pattern
Drunk Eliza
naked on pluto
100.000.000 stolen pixels
Incorrect Music 2

featured projects
LYCAY (Let Your Code plAY)
Reject Me
Outsource me!
The Invisible Hand Machine
Towards a Permanently Temporary Software Art Factory