Self-reference in computer programming and hip-hop

Like this sentence, computer programs and songs can refer to themselves. Many computer programs and songs are made of loops within loops within loops. Self-reference gives computers their extreme versatility. It also makes for richer, more interesting music.

http://www.flickr.com/photos/jerkhaircut/3538413244/

Self-reference and looping in computer programs

When I was in fifth grade, we did some programming on Apple IIe computers using Sprite Logo, a student-friendly version of the venerable programming language Lisp. In Sprite Logo, you write commands that move a cartoon turtle around the screen (back in the eighties, it was more just an abstract triangle.) The turtle has a pen attached to its tail, and by specifying its path around the screen, you can make it draw shapes. By default, the turtle begins in the center of the screen, pointed up. Here’s how you tell the turtle to draw a box one hundred pixels on a side, in Logo-like pseudocode:

go forward 100 pixels
turn left 90 degrees
go forward 100 pixels
turn left 90 degrees
go forward 100 pixels
turn left 90 degrees
go forward 100 pixels
end

Here’s how you make the turtle draw an equilateral triangle:

go forward 100 pixels
turn right 120 degrees
go forward 100 pixels
turn right 120 degrees
go forward 100 pixels
end

You can tell Sprite Logo to repeat parts of the program by having it repeat parts of itself, using notation very similar to repeat markers in music. You might draw your square by defining a procedure to draw a single side, and then tell the program to repeat this procedure four times:

repeat 4 times: (go forward 100 pixels, turn left 90 degrees)
end

Here’s how you’d draw the triangle using repeats:

repeat 3 times: (go forward 100 pixels, turn right 120 degrees)
end

You could draw five triangles spaced two hundred pixels apart like so:

repeat 5 times: (repeat 3 times: (go forward 100 pixels, turn right 120 degrees)), go forward 200 pixels)
end

A more modern way to draw five triangles is to create procedures called “square side” and “triangle side,” and then have the program run them a certain number of times:

define 'triangle side' as (go forward 100 pixels, turn right 120 degrees)
define 'triangle' as (repeat 3 ('triangle side'))
repeat 5 ('triangle', go forward 200 pixels)
end

This kind of nested self-reference is so common in computer programming that it’s easy to forget how weird it is. Computer programs use the same code for both programs and the data that the programs are acting on. In other words, programs can use themselves as data. They can take their own code as input, and can output code too. You can nest layers of self-reference within self-reference in your programs to whatever depth you want. Such self-referential nesting is considered good programming technique, and most of the software we use every day is full of it.

Self-reference and looping in music

Music is full of self-referential loops. No form of music is more self-referential than hip-hop. In “My Melody” by Eric B and Rakim, Eric B takes the line “Check out my melody” and re-sequences its DNA, live on tape, using a sample of the song itself:

Ch-ch-ch-ch-check out, check out check out my melody.
Ch-ch-ch-ch-check out, check out check out my melody.

Digital audio supports effortless and endless recursion. You lose a little signal quality duing the encoding process, but once you have your list of ones and zeros, you can copy it flawlessly across any different medium, as many times as you you want. It’s not uncommon for DJs and producers to heavily sample themselves, or their own projects, and it’s not uncommon to use samples of samples of samples.

recursion-in-hiphop1

Any song that samples the ubiquitous “Funky Drummer” remix is already a remix of a remix. This is before we come to the uncountable thousands of samples of tracks based on samples of the remix, or samples of those tracks.

A particularly remarkable knot of self-reference is “The Score” by The Fugees, from their album of the same name.

“The Score” is based on samples of “My Melody,” “Dove” by Cymande and “Planet Rock” by Afrika Bambaataa, itself based on interlocking excerpts of other tracks. “The Score” also includes samples from every other song on the album “The Score”, and those songs mostly contain samples of still other songs:

Fugees - "The Score" sample map

Douglas Hofstadter thinks that self-reference is the key to consciousness. That could explain why it’s such a source of fascination for me: I’m seeing a reflection of myself.

3 replies on “Self-reference in computer programming and hip-hop”

  1. Thanks for the information bro, I personally am a huge fan on J Cole’s music, maybe you could try looking into that?

    Otherwise I know J Cole is a huge fan of Nas, so regardless I am able to relate.

    Your blog has been very helpful,

    Thanks
    K

Comments are closed.