Telling a Story with Code

Warning:  Esoteric Nerd Thoughts Ensue

An idea has been forming in my tiny little mind for the last week or so pertaining to a combination of the evolution that code goes through within a single application during its development and the evolution that a narrative story and its characters go through as the reader partakes.  That sentence came out longer than I wanted it to, so let me simplify.

When writing software from scratch, the code that makes up that software changes during its development.  A developer will start to solve one bit of the requirements using one method, but then switch off to favor a different method once another requirement presents itself as problematic to integrate with.  Test Driven Development practices are one terrific way to make your code evolve in directions you wouldn’t have previously considered.

Similarly, any well written story, fiction or non, typically involves the evolution of the characters in it as they progress from some pre-condition to some post-condition due to the direction the drama takes.

So my idea: what if we combined these?  I’m wondering if there is a way to combine the story telling aspect of prose narrative with the code deciphering aspect of working on a software project.  While reading through an existing app’s code to figure out how its running under the hood, I scan through class definitions and functions, following Visual Studio’s “Go To Definition” option through as many turns as possible.  Code has many of the same elements that spoken/written languages have.  There are objects that serve as subjects, functions that serve as verbs, properties that serve as adjectives. 

I think this is possible…  A narrative tale told through code would have to be completely nonlinear as the “reader” would have the ability to open all source files at the beginning and read wherever he so chooses.  The trick to the story telling is to architect the code in such a way that you guide at least a majority of your readers through the dependancy structure in such a way that each function they read will make them want to follow the logic further to see what the next method or object is doing.  The comments in the code themselves could even become a form of meta communication that could be a layer of story of its own.

I want to try this.  If I’m successful I’ll publish the code as open source and let other nerds partake.  Now I just have to think of a plotline that can be expressed in C#…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: