sketches for students of english

code is a language. some schools even allow you to substitute a class in C for French or German. consider these parallels:

  • code specifies linguistic constructions: nouns and verbs, sentences and paragraphs
  • code is executed in a linear fashion
  • code read aloud becomes a narrative

reading code is an excellent way to get familiar with the parts, and that eventually one could make the leap from translation to thinking directly in code. though we usually think of code as manipulating abstract symbols, code also generates narrative and metaphorical space.

consider this example, try covering each side. could you translate from processing to english and from english to processing?

processing
void draw() {
  background(224);
 
  // the plot area is a white box
  fill(255);
  rectMode(CORNERS);
  noStroke();
  rect(plotX1,plotY1, plotX2, plotY2);
 
  drawTitle();
  drawAxisLabels();
 
  stroke(#5679C1);
  strokeWeight(5);
  }
english
function "draw" accepts no arguments and returns void.
start function draw.
set the background to gray 224.
comment: let's draw a white box behind the plot area.
set the fill to white.
set the rectangle mode to CORNERS.
run/activate the noStroke function.
draw a rectangle with corners:
            plotX1, plotY1, plotX2, and plotY2.
run your drawTitle function without arguments.
run your drawAxisLabels function without arguments.
set the stroke to hex value 5679C1.
set the stroke weight to 5.
end function draw.
exercise 1

I am going to read a chunk of processing code. I would like you to transcribe it in the processing IDE, compile it, put it in your pages folder and post your name and link below.

exercise 2

write a sketch that prints its own code on the canvas (something like a quine) 1)

  1. get a partner:
  2. - read your code in english for your partner to transcribe.
  3. - help your partner get the transcribed code to run without showing the original code.
  4. reverse roles and repeat.
  5. merge the two patches into one better patch to share with the class.
1) In computing, a quine is a functional metaprogram that produces its complete source code as its only output. see wikipedia entry. bonus round awarded for writing a true quine!
 
vm464_07.txt · Last modified: 2008/05/06 15:07 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki