Code is Poetry, Pt. 2: Genesis
By Ersin Akinci

Can we tell the creation of man in Ruby?
To begin my project to write history in Ruby, I’ve taken notes on a short passage on the Biblical account of the creation of the world and included commentary that begins to explore the issues involved with writing non-programs in a programming language. The result is not just notes or code, but a new way of evoking emotions and some early glimmers of a new kind of literature.
—
Why Ruby?
Before I get into the code, I’d like to comment on my selection of Ruby. For those who are uninitiated, Ruby is a scripted language perhaps most commonly associated with large Web 2.0 projects (like Twitter), but is also a powerful general purpose language for writing all kinds of programs. It has a hard-earned reputation of being fun and “natural” with clutter-free syntax and intuitive features. For instance, a for loop in C such as
for(int i = 0; i < 10; i++)
{
printf("Hello!\n");
}
can easily be written in Ruby as the following:
10.each print "Hello!"
Such aspects of the language encourage a more interactive, to-and-fro, and downright zippier style of programming known as agile development. In the business world, agile development encourages creating prototypes for clients rapidly while constantly changing and tweaking them based on continual feedback rather than a static plan fully predetermined from the beginning. This often means that Ruby-coded programs are light on initial design and emerge organically, a tendency which would seem to heed Bruce Blum’s observation that in programming the design and the product are the same.
I would amend Blum’s insightful principle by asserting that a program’s design and the program itself are, for most purposes, practically the same, and in this respect Ruby more closely resembles written natural languages than any other programming language. Perens’s point was that when creating software, we can imagine that the code is a blueprint for the program, which in actuality is a set of instructions that we want the computer to execute. Since the code is the set of instructions, however, the blueprint and the program are equivalent. Yet even before we begin to code, whether there is a formal design phase or not, undeniably the coder imagines in broad strokes what “should happen”, and it is this pre-design “phantasmal ratio” that gets distorted in the coding process. Surely for each programmer it is something different; for me, I often see images of gray windows and frames moving around, and when I contemplate iterations I feel a soft, upward tension in the back of my throat and a warmth where my head meets my neck. These are incommunicable regardless of language, and yet from thence does the code come out.
Isolating and defining what mental or spiritual paths or processes the code uses to come out seems nigh impossible, but I do feel that when it does come out we can either be equipped with a language that first demands pseudo-code, which seems like an extension of the pre-design phantasmal ratio into design proper, or it can be birthed straight into real code if the language is prepared or ready enough. Ruby is ready to receive the code directly just as natural languages are also ready to communicate our imagination and our thought immediately, as when we speak in a conversation, and this is why I’ve chosen Ruby for my project. This ability to receive our mental impressions more immediately than at least the programming languages that I am familiar with is, in my opinion, greatly responsible for Ruby’s tendency toward agile development, which is another similarity with how natural languages are used and yet another reason to use Ruby to write my notes.
In Principio: notes on the Christian creation of the world
For my first attempt, I’ve selected a short passage from “In Principio: The Creation in the Middle Ages” (in “Approaches to Nature”, ed. Lawrence D. Roberts. Binghamton, NY: 1982, Center for Medieval & Early Renaissance Studies), a scholarly article by Dorothy Glass on approaches used by medieval artists’ to depict the Biblical account of the creation of the world. My intention for this initial example is not to create a thorough set of notes covering the entire piece, but rather a focused exposition of some of the issues involved in coding one’s notes in Ruby. By no means is my list exhaustive; as a matter of fact, perhaps the greatest obstacle is that I am so aware of how creative an act my project is (even though it is no more creative than any other), a creativity which I have endeavored to protect by limiting my own commentary. Some of my decisions will undoubtedly, therefore, seem controversial, and I hope that the reader will meet my creativity with their own uninhibited and unwittingly creative notes and observations. The passage is as follows:
“The creation stands at the beginning of all nature. In the Middle Ages, the Hexaemeron, or six days of creation, was both a topic of extensive debate and the subject of innumerable illustrations in all media. Interpretations of creation both written and visual encompass theology, philosophy, mathematics and even architecture — in fact, virtually the entire intellectual life of the Middle Ages…
The creation, as recounted at the beginning of Genesis, is seemingly well-known, and one can easily visualize a series of illustrations depicting the days of creation. In actuality, chapters 1 and 2 of Genesis are drawn from different traditions. Chapter 2 repeats some of the essentials of Chapter 1, but also offers conflicting information and interpretations. The text must be carefully analyzed in order to appreciate the problems faced by medieval artists in their attempts to envisage the story. It will soon be evident that medieval artists must not be viewed as mere illustrators.
For example, during the six days of creation recounted in Gen. 1, God actually performed eight separate acts. On the third day, He created not only the dry land (or earth), but also grass, seeds, and fruits. On the sixth day, He created the beasts of the earth and both man and woman who were given dominion over them. The artist was thus faced with a choice of events to be depicted with the canonical six days. The solutions to this problem are myriad.” (pp. 67-8)
My first thought: creation is the first node in a linked list. What does that mean? The list could contain objects all of the same type, perhaps of class “Event”. The structure of a linked list is linear, which is appropriate for a Judeo-Christian conception of time. Add a link back to the first node at the end and we have a Greco-Roman history, a loop. Should the list be doubly linked? No, at least not in any publicly accessible way. So we start:
class TheCreation
(NB: Ruby classes are CamelCased by convention, which wreaks havoc with semiotics.) Right here, I get distracted by the eight acts during the six days of creation that artists had difficulty portraying. A hash would be a perfect way of representing both the difficulty and the objective of those artists. Each stained glass window and its depicted scene is like a key pair, but if there are eight values then how do we assign them to only six keys? We continue:
class TheCreation
days = {
I’ve started to write the hash, but now there’s a bevy of problems. First, one related to Ruby itself: hashes, arrays, and other variables cannot be declared within a class while outside of a function. The Ruby way of doing what I’m trying to do here would be to initialize the hash at the time of the initialization of a TheCreation instance, but this is a little absurd. Were the numbers of days and acts and their assignments determined at the moment of creation? More importantly, the Biblical creation was unique, but with Ruby, I can create as many instances of TheCreation as my memory can hold (seems like Plato had something with his theory of recollection).
Another problem involves scope. Ruby allows instance, class, and global variables, each of which has problems. Using an instance variable for the hash is perhaps most objectionable, as it further ramifies the error of multiple creations. A global variable might be more appropriate, but the fact that it is accessible from anywhere means that everyone has a direct connection to God, which is downright Protestant, not to mention that any method could fidget with the hash, assigning new key pairs and so forth. A class variable seems reasonable, but then the variable won’t exist before an instance of TheCreation is initialized, whereas God might have prefigured the days and acts before the moment of creation.
In fact, all of these issues were hotly debated by medieval scholars, only in terms of theological constructs rather than variables and instances. Attentive readers will have also noticed some of the same patterns in the argument above can be found in medieval treatises, such as the reductio ad absurdum and a way of treating language that vaguely resembles suppositions. Is the resemblance coincidental, or are programming and medieval theology (or forms of argumentation) intrinsically linked? Perhaps it simply boils down to the bias of my own methods in collusion with the medieval content of the subject matter I am studying. That is, since I know high medieval writings, I pattern my commentary (indeed, my commentary) around them whenever anything medieval and intellectual is to be discussed.
Coded notes as poetry
I suspect that my bias is an important part of the answer, but only one part. Language is infinitely flexible and can be used here as both commentary or art, for instance, since the dividing line is so thin. Were I to abandon the mimetic aim of my notes and go with whatever feels natural, all of a sudden my coded notes become an unexpected statement, an unthought idea; a poem:
class TheCreation
attr_reader :days
def initialize
@days = { :day1 => nil, :day2 => nil, :day3 => nil, :day4 => nil, :day5 => nil, :day6 => nil }
end
end
c1 = TheCreation.new
c1.days.each { p "Hello, world!" }
Then, and only then, do the scholars come in stage left with our expert opinions on the act of creation. Here, rather than posing a problem, the infinite flexibility of language allows us say that we were right all along, just as the scholastics did. Why did I initialize the days hash with instance-wide scope? Because, in fact, multiple instances of TheCreation, or at least multiple universes in the sense that the universe contains and is everything, are possible since God is omnipotent, and this has been the official position of the Catholic church since 1277 when Étienne Tempier, bishop of Paris, issued his condemnations prohibiting the theological faculty at the University of Paris from debating certain “errors” of Aristotelian philosophy including the uniqueness of the world (the eternity of the world having been a prohibited belief since 1270). For the same basic reason, we can also rule out the need for a doubly linked list of events with TheCreation as the first node. Finally, the entire question of scope can be handled within the framework of suppositions, where $days (global) is in simple supposition, @days and @@days (instance and class) are in personal supposition, and :days (symbol) is in material supposition.
Yet my code stands outside of these attempts to reconcile my text with the Bible, and if we contemplate it independently, doesn’t it have a curious force of its own? Is it a farce that God’s six days of creation are merely symbols in material supposition that are matched with nil values? And when the user runs the program, it outputs what the artist wants her to see, in this case “Hello, world!” for each day of creation. Programmers will get the reference: writing a program that prints “Hello, world!” on the screen is the classic “first program” that one writes when first learning a computer language. Am I suggesting, then, that I am newly learning Ruby, or perhaps that God was just getting his grips on creation when he made our world? When I contemplate this, I am moved to wry laughter and my soul feels a bit nourished.
Maybe the power is relative and I am the only one who feels this way about my code. Certainly my experiment has not been the first to formulate commentary in computer code, though I have not found other samples as stirring as mine. An example that has always stuck out in my mind is the snippet at Rastasoft, which features the following lines of C superimposed against a red, yellow, and green flag background:
while ( love & passion ) {
for( fight = 0 ; rights < freedom ; rights++ )
fight = standup( rights );
free( babylon );
}
Why does this code not move me? It should be noted that the author has even gone out of the way to appeal to our sensibilities by using the technically incorrect expression “love & passion” instead of “love && passion”. Well, not incorrect, but using one ampersand has a completely different meaning than what is intended, which is loosely translated into English as “while there is love and passion, we will stand up for our rights, fighting from nothing until we’ve attained freedom, at which point Babylon will be freed”. Quite a stirring anthem, except that my translation falls short of what is actually going on in the code and the assumptions that we must make if we are to take this line of thought to its logical conclusion. Standing up for our rights does not involve our actual rights but merely copies of them (passing by value) and what matters is the number of rights we have instead of the specific ones (“rights” is an integer, the for loop’s exit condition is when rights is incremented up to a certain value). Nor are we technically standing up “for” our rights, but really we are using our rights or the issue of our rights as the basis for our act of standing up. For that matter, when we say “fight = standup(rights);”, literally we are saying that the fight should “become” (be assigned) the outcome of standing up while using our rights rather than what is presumably intended, which is that standing up for rights is the fight (which, in turn, would be closer to something like “fight == standup(rights);” or even using function pointers using “int (*fight)(int) = standup(rights);”).
That batch of nonsense, which I have admittedly tweaked to give a slightly negative-sounding tone and hence a semblance of poetic meaning, is partly a result of the author’s ambiguous liberalities with the programming language, but also partly the necessary outcome of C’s weird syntax. The need to go through a linear progression of gaining rights until we reach freedom necessitates a for loop, which is the most direct way to increment continually, while in Ruby we might more naturally use a variable’s “each” method. That would also free us from having to represent rights as a number.
What’s missing from both my code and the Rastasoft code, however, is a compelling dramatic narrative, more so for the latter than the former. That’s no surprise given that one is just a set of notes and the other is almost like a motto or a rallying cry, and more code would certainly leave room for a plot with different actors (classes). Indeed, the beauty of coding notes or literature might be the possibility of combining classes and objects into new orders, connecting them by passing variables and overloading methods, etc.
Stay tuned for part three!

The Code is Poetry, Pt. 2: Genesis by Ersin Akinci, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.










Hey Ersin – just found this through Twitter. Haven’t had time to give this the proper readthrough that it deserves (or formulate an appropriate response) but I would be remiss if I didn’t refer you to this song (mp3 link, lyrics here.
Social comments and analytics for this post…
This post was mentioned on Twitter by ruby_news: Rewriting the Bible in Ruby http://bit.ly/ap13vU...
“Am I suggesting, then, that I am newly learning Ruby, or perhaps that God was just getting his grips on creation when he made our world? When I contemplate this, I am moved to wry laughter and my soul feels a bit nourished.”
Ah. The platypus must have been where we had a case of “hey, let me try out all these different wacky functions and see how they work together.”
First off, if you’re writing history in Ruby, then why the creation story? That’s not history!
Secondly: “[...] variables cannot be declared within a class while outside of a function” is wrong. Every line in Ruby is executed. Storing it into a local variable will only make it disappear when the block has ended.
I would write the creation story more like this:
class Creation
extend TimeLine # time was apparently already there
day 1 do
create :Light
end
day 2 do
create :Firmament
end
# etc...
day 6 do
create :Beast
create :Man
end
end
So, since time was already there (it had days), I think of it as a module:
module TimeLine
def day number, &acts
puts "On day #{number}, #{God.performs(&acts)} and saw that it was good."
end
end
That reminds me, there is also a God. There is only one God, so let’s create some sort of singleton.
God = "God"
def God.performs &acts
instance_eval &acts
end
def God.create something
"#{self} created #{something}."
end
def God.rests
"#{self} rested"
end
sorry, the indentation was gone during posting… I made a Gist with all the code: http://gist.github.com/331926
Thanks for this tip, and also for correcting my mistake in my notes on Genesis
I’m a bit of a beginner, as you can see. What I meant about “[...] variables cannot be declared within a class while outside of a function” was that something like this…
class God
attr_reader :name
@name = “God”
end
zeus = God.new
zeus.name
…will not print out “God”, since @name == nil.
Thank you very much, too, for your take on Genesis: it was quite beautiful. I can’t help but chuckle that you’ve made God a string and just added functions to it (I love that about Ruby). It suggests his arbitrariness, almost as if the word is a permanent placeholder; when we ask “What is God?” we get the reply “God”. Though the value of God is not permanent! I mean, there aren’t any constants in Ruby, right? We could use a symbol, but that has its own host of issues. At the same time, making God a string suggests some kind of universality and essential nature.
Yes, why write creation if I’m trying to write history; a very good question. I think my point is that when we normally take notes on, say, a historian’s commentary on Genesis, we recognize it as notes. When we try to describe what that historian is saying in code, however, all of a sudden it _becomes_ Genesis itself rather than notes on the history of it.
class God
attr_reader :name
@name = “God”
end
Fire up IRb and figure out why this doesn’t work
instance variables are stored in “self”. So, if you say “@name = ‘God’”, ask yourself: “What is self?” Try it:
class Godputs self
end
you get: “God”. Not an instance of God, but the class itself.
So, you could write this:
class God
@name = 'God'
end
def God.speak
puts "I am #{@name}"
end
No, nothing is constant in Ruby, not even constants. And the values people claim God to have are not constant either.
Symbols cannot accept singleton methods due to the fact that they are not really full blown objects, but memory addresses.
Since you like Ruby’s very flexibility, you might also enjoy “Tribute” by Tenacious D, written in Ruby: http://judofyr.net/posts/tribute.html
[...] What Digital Revolution? » Blog Archive » Code is Poetry, Pt. 2: Genesis w (tags: writing philosophy art aesthetics programming language history interpretation hermeneutics) [...]
[...] probably WikiCreole goes further in that respect than either. There was this guy who wanted to write the genesis in Ruby, maybe we need more of those experiments… « [...]
Leave your response!
Recent Posts
Recent Comments
Tags
Blogroll
Most Commented
Most Viewed