In my last comment I suggested that code, as a language system, may offer greater possibility for logic/narrative integration than might be possible in a “purer” system, such as natural or mathematical language. I guess I should probably expand upon this reckless and highly undisciplined conjecture.

I’ll begin with the very true statement:
“I love to go ice skating”

Permuting the word order some, we get:

“To go Ice skating I love”
“Ice skating I love to go”
“Love to go I ice skating”
“Love ice skating to go I”
“Ice skating to go I love”

Somehow the literal meaning of the original statement seems to remain fairly stable in the permuted variations (even without the aid of explicit syntax.) There are of course subtle shifts in expressive/poetic (connotative) meaning, which I‘ll leave for others to explain. Natural language seems especially suited to this type of fuzziness, allowing for amazing structural variations, without the (complete) loss of literal meaning. In mathematics, some similar flexibility exists, specifically through the commutative property:

45 + 65 + 193 + 200 = 503
65 + 45 + 200 + 193 = 503
200 + 193 + 65 + 43 = 503

50 x 20 x 2 = 2000
20 x 2 x 50 = 2000
2 x 50 x 20 = 2000

Using only the addition or multiplication operators in an expression, operand order doesn’t alter the evaluated value; nor does it impact expressive value. Mathematical language structures were obviously not designed to connote, but rather to definitively denote. For a simple visual explanation of commutativity. Beyond the commutative property of addition and multiplication, operand order usually alters an expression’s value:

50 – 20 x 2 = 10
50 x 2 – 20 = 80
(remember we evaluate multiplication before addition.)

In most instances, changes to operand order within expressions, as well as associative groupings (e.g. 2+3 – 6 x 5 = 30, (2+3 – 6) x 5 = -5), dramatically impact value.
(stuff between parentheses are always evaluated 1st.)

Both natural language and mathematical language are functionally efficient systems. Using the former, I can say “I love you” to my parents, grandparents, siblings, spouse, children, etc and each will take away a different meaning from the statement. The fuzziness provides utility along with the possibility for semantic expansion (my son can learn to love his pet crayfish.)
Using mathematical language, an engineer can calculate the tensile stress of an aluminum wing and communicate this value with absolute precision, without the risk of multiple interpretations–which has some benefit when you’re flying 5 miles over the Atlantic at 600 MPH.

Both natural and mathematical language systems are absolutely fundamental and at the core of, well everything; yet, they seem diametrically opposed (with regard to their defining strengths: fuzziness vs. precision.) I would also (very very politically incorrectly) argue, based on personal experiences working with both Computer Scientists/mathematicians and Artists/”Humanitists”, that the 2 language systems seem to inculcate a bias within their most ardent practitioners. I see this bias also express itself within the digital media classroom, where the majority of my students (upon entering my class) define themselves either as creative or analytical.

It is this divide, between the mutable fuzziness of natural language and the rigid precision of mathematical language, that I’d like to try to put together in a discussion on code, as a potentially integrating language system. However, as this post has already gone on far too long, I will only discuss a few procedurally based code structures. In a later post, I also plan to look at some object-oriented constructs. The code examples to follow will run in the latest version of Processing. If you haven’t checked out Processing yet I highly recommend it; although, I’m somewhat biased.

Variables:
Variables symbolically link a word (identifier) with a stored value (either directly or indirectly).
VariableName = variableValue

There are some rules defining legal identifiers, but essentially any word is valid. Besides an identifier, variables (within Processing and many other languages) are declared of a specific datatype. The datatype limits the type of data that may be associated with the identifier. Some common predefined datatypes include: int, float, String and color.
The complete declaration of a variable:
datatype VariableName = variableValue

Declared variables, as their name implies, may be assigned new values (of their declared datatype.) It is also possible, but outside of the scope of this post, to even create new custom datatypes.

Below are 5 complete and legal variable declarations, followed by a legal reassignment.
int daysOfTheWeek = 7;
int currentAge = 40;
float bodyHeat = 98.6;
String name = “ira”;
color warmth = 0xFF772A;

legal reassignment:
warmth = 0xEE0012;

In each of the statements, the initial term is the declared datatype, followed by a unique identifier, the assignment operator (“=”) and an assigned value. Each expression is terminated by a semi-colon. Variable declarations occur from right to left. So the first declaration above reads: the value 7 is assigned to the identifier daysOfTheWeek. It is a convention to capitalize the initial letter of compound identifier names-for readability.
Below are 2 new additional legal assignments, followed by 2 illegal ones.

Legal:
daysOfTheWeek = 2;
currentAge = daysOfTheWeek;

Illegal:
Warmth = bodyHeat;
currentAge = “forty”;

The initial 2 assignments meet the requirements of assigning the correct types of data to the respective variables. The 2nd statement, which might look odd to non-coders, is perfectly legal as the variable on the right (daysOfTheWeek) is 1st evaluated to 2, prior to being assigned to the variable currentAge.

The 3rd assignment statement (Warmth = bodyHeat;) is illegal because the datatypes of the variables do not match (color vs. float). Although interestingly, the assignment statement, vis-à-vis a natural level reading, seems semantically sound–body heat would generate warmth. The 4th expression is also illegal because of another datatype mismatch.

It seems that this type of assignment syntax offers interesting potential for a multi-level reading of the code, with a (natural language) narrative level (“supertext”) above a (mathematical language) logical execution level. And as was illustrated in the 3rd assignment expression above (Warmth = bodyHeat;), there can exist an interesting tension between the 2 readings.

The variable is the most basic and fundamental code structure, yet even simple assignment operations seem to illustrate an integration of natural and mathematical language systems (fuzziness and precision). Another common code structure that offers a more interesting, (or at least more fun) example of this integration is the random number generator, which we’ll look at with a visual example.

Above I tried to illustrate the fuzziness of a word like “love”, simply to emphasize the connotative range of natural language. Thus the 2 statements:
I love my ice skates
I love my mother
although structurally similar are obviously not semantically similar (or shouldn’t be ;-))

In contrast, here’s an algorithm to generate a 3-sided polygon (yes, it’s also a triangle), centered at coordinate (200, 200) with a radius of 150. Below the algorithm is some processing code that implements the algorithm. To run the code: launch Processing and paste the code into the text editor, and then press run (top left right-facing arrow) or you can use a shortcut: (OS X) command + r or (Win) control + r.

Algorithm:
Loop 3 times:
Set x = 200 + cosine(theta) * 150
Set y = 200 + sine(theta) * 150
Plot (x, y)
Increment theta by 360/3

Processing implementation:
void setup(){
size(400, 400);
background(255);
float angle = 30;
beginShape();
for (int i =0; i<3; i++){
float x = 200 + cos(radians(angle))*150;
float y = 200 + sin(radians(angle))*150;
vertex(x, y);
angle += 360/3;
}
endShape();
}

The algorithm, as it is currently written, will always generate a 3-sided poly, with a radius of 150 & center point at 200, 200 (kinda boring.) Normally, we would want to functionalize this type of algorithm to at least allow any n-sided polygon to be generated and also provide parameters to control the poly’s center point and radius.

Here’s a more generalized poly algorithm:
Loop n times:
Set x = circle center along x + cosine(theta) * circle radius
Set y = circle center along y + sine(theta) * circle radius
Plot (x, y)
Increment theta by 360/n

Processing implementation:
void setup(){
size(400, 400);
background(255);
// generates a hexagon
createPoly(6, 75, 200, 230);
}

void createPoly(int vertices, float radius, float centerX, float centerY) {
float angle = 30;
beginShape();
for (int i=0; i<vertices; i++){
vertex(x, y);
angle += 360/vertices;
}
endShape();
}

This is an improvement, but still a far more rigid structure than our love example. Finally, we can add randomization into the function and even the function call to generate a fuzzy implementation of a precise polygon creation machine. I’ll skip the algorithm and just include a Processing implementation:

void setup(){
size(400, 400);
background(255);
noStroke();
int polys = int(random(1, 20));
for (int i=0; i<polys; i++){
createPoly(10, 200, width/2, height/2, 70);
fill(random(255), 100);
}
}

void createPoly(int vertices, float radius, float centerX, float centerY, float rand) {
float angle = 30;
float randvertices = random(3, vertices);
beginShape();
for (int i=0; i<randvertices; i++){
float x = centerX + random(-rand, rand) + cos(radians(angle))*radius +   random(-rand, rand);
float y = centerY + random(-rand, rand) + sin(radians(angle))*radius +   random(-rand, rand);
vertex(x, y);
angle += 360/randvertices;
}
endShape();
}

This fuzzy algorithm now begins to generate something which has certain aesthetic attributes, beyond simply being the precise output of a poly creation algorithm.

And with that I’ll put this ridiculously long post to bed.

• mandellc
• Posted May 23, 2006 at 1:43 pm

“Supertext” differs dramatically then from a metalanguage — a metalanguage would be comments in a program. So you are imagining a functioning program that somehow made legality and semantic soundness converge, stretching semantics as well as code (in an artistic way)?

Rita Raley’s essay “Interferences: [Net.Writing] and the Practice of Codework summarizes a lot of work on operational code art:

• 