Choreographing An Algorithm — Part 4

Let’s Move

First thing! Here’s the video of the movement as promised in the blog post before this:

What I haven’t mentioned in previous posts is that while learning JavaScript last year, I noticed similarities between code and choreographed movement.

For example:

I liked to compare functions to phrases of movement. In dance, we’ll have a phrase of movement, let’s say it’s 1 minute long. And the way we know to begin that phrase is because we hear a musical cue, or see a movement cue, or hear a vocal cue. To me, this feels similar to calling or invoking a function using a click or other events.

Loops were familiar to me because when I would improvise onstage I’d have a piece of phrase work to iterate over it in some way. I’d reverse it, or do it on the floor or do it inversely to how it was originally choreographed.

There was structure but because it was an improvisation, I was working through the movement on the fly. And so I would continue looping around from the beginning of the phrase, adding something more with each round, eventually ending up with or “returning” a full phrase.

In an attempt to understand code better, I decided to combine something I’m familiar with (dance/movement) with something I’m hoping to become for familiar with (programming).

Let’s go back to the beginning and I’ll talk about how I derived movement from code.

First, I:

  • Decided this would be a solo endeavor to begin with. I want to put the movement into my own body so I can own the code and the movement.
  • Wanted an algorithm whose JavaScript implementation would conjure movement. That means lots of verbs (pushing, looping, popping, etc) and nouns (arrays, strings, tables, etc).
  • Also wanted the implementation to be simple or simplify-able
  • After thinking about it for awhile realized that most if not all algorithms could fit this mold. They can all be dynamic and in order to implement and understand them, they need to be simplified.
  • Landed on the Finding the Longest Common Subsequence Algorithm.
  • Initially matched movements to each character of each sequence, using Laban Movement Analysis. You can read more about how I did that in the previous blog post.

After the above list items I was able to create the video at the top of this post.

But then it occurred to me that if I’m choreographing the implementation of the algorithm, then the choreography will come from the code itself. So I had to… implement the algorithm in JavaScript!

Here is the first part of the implementation:

The outer and inner loop create a table that looks like this:

The second part of the implementation walks through the table and the two sequences with if statements and comparison operators. It looks like this:

Then the Longest Common Subsequence is pooped out. Yay!

Once I had the implementation in my hands, I found the verbs and nouns that would be useful in the choreography.

Verbs:

  • pushing
  • comparing
  • sorting (Math.max)

Nouns:

  • strings
  • arrays
  • a table

After sussing those out I mulled over the code a bit more.

I wrote what the algorithm was doing in somewhat plain english. Here’s a tiny snippet of what’s happening with the outer and inner loops:

lol does this make sense to anyone besides me?

Then I didn’t adhere quite as strictly to Laban Movement Analysis when choosing movement qualities. Instead I relied on my experience with ballet and modern dance techniques in addition to Laban, to create movement that felt good in my body. And the purpose of this entire endeavor was to put code into my body and make it more relatable to me, so I’m feeling good about this!

Here’s a speedy video of the outer and inner loops until the table is fully created choreography:

The quick spins around denote the beginning of a new outer loop. The swoops around the head are zeros being pushed into an array. Any time both hands are out in front looking like I’m saying “stop” is a push into an array.

Check back for the next post in which I’ll show the entire algorithm implementation with movement.

And for a more comprehensive understanding of my choreographing an algorithm process, here’s the talk I gave at WaffleJS. Enjoy!