# 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.

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

Nouns:

• strings

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:

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!

I’m just a girl, standing in front of some code, asking it to love her.

## More from Morgan Fogarty

I’m just a girl, standing in front of some code, asking it to love her.

## Image Processing Pipeline — a modern image build orchestrator

Get the Medium app