The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

20
The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost

Transcript of The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Page 1: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

The Poetics of Code

LCC 2700: Intro to Computational MediaFall 2005Ian Bogost

Page 2: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Aesthetics

The philosophy of art

Immanuel Kant (18th c) - the philosophy of perception

The criticism of taste

Literary, Visual, Gastronomic, Musical…

Page 3: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Poetics

Aristotle, a subset of aesthetics (with rhetoric)

The first literary theory

On poetry: a form that carries out imitation

Principally advice on writing tragedy

Completeness: beginning, middle, endUnity of action: plotStruggle: agôn

Comedy: imitation of “low” behaviors (presumably to encourage avoiding them)

Page 4: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Programming

• We’ve been talking about procedurality as it produces expression

• But is programming itself art?

Page 5: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Programming Style

• Standards for composing code• Readability

– Variable names– Consistency– Comments

• Typography– Indentations– Line breaks– Searchability

• Naming– Evocative variable names

Page 6: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Hungarian Notation

• A naming convention in which the name of a variable indicates its type

• Prefixes for variable names– strName, sName– intAge, iAge– lngUserId, lUid– datHireDate, datHire

Page 7: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Programming Efficiency

• Class structure– Careful use of inheritence– Final and other special

directives– Methods should do one thing– When to class based on the

environment (J2SE v. J2ME)• Use error control for exceptions,

not for flow control• Python forces indentation for

control flow

Page 8: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Coding Standards or Conventions

get a b c

if a < 12 and b < 60 and c < 60

return true

else

return false

if(hours<12&&minutes<60&&seconds<60){return true;}else{return false;}

get hours minutes seconds

if hours < 12 and minutes < 60 and seconds < 60

return true

else

return false

if (hours < 12 && minutes < 60 && seconds < 60)

{

return true;

}

else

{

return false;

}

Page 9: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Programming Style

• Focused on productivity

• Collaboration and complexity

• Taken for granted (consider auto-formatting IDEs)

• Code as seen only by technical workers, and only used to produce programmatic output

Page 10: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Programming Languages

• Themselves designed for maximum productivity

• Object-oriented programming as a kind of Fordist manufacturing process

• “Automatic Factory”?

• Produce “poetic output”

• Facilitate “poetic productivity”

Page 11: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Code and the Program

• HTML as a possible example

• The markup and the layout are both viewable to the end user

• The markup’s “quality” is part of the experience

• “How did they do that” (e.g., the single pixel)

Page 12: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Upsetting the constraints of languages

• International Obfuscated C Code Contest

• Hello World

• Palindrome

• She Loves Me…

• Poot

Page 13: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

New Languages

• Entire programming languages devoted to constrained code-level and execution-level expression!

• Alternate flow control: Whenever• Compresion: Brainfuck• Programming from Hell: Malebolge• Statement redundancy: Ook• Code as visual aesthetics: Piet• Code as literature: Shakespeare • Code as cooking: Chef

Page 14: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Hello World in Brainfuck

++++++++++

[

>+++++++>++++++++++>+++>+<<<<-

] The initial loop to set up useful values in the array

>++. print 'H’

>+. print 'e’

+++++++. 'l'

. 'l’

+++. 'o’

>++. space

<<+++++++++++++++. 'W’

>. 'o’

+++. 'r’

------. 'l’

--------. 'd’

>+. '!’

>. newline

Page 15: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Hello World in Brainfuck

• ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

Page 16: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Hello World in Malebolge

(=<`:9876Z4321UT.Q+*)M'&%$H"!~}|Bzy?=|{z]KwZY44Eq0/{mlk** hKs_dG5[m_BA{?-Y;;Vb'rR5431M}/.zHGwEDCBA@98¥6543W10/.R,+O<

Page 17: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Project 7 - Write a program in Chef

• It must compile and run. It need not be the most meaningful program, but it must execute and do something coherent

• It must read like a coherent recipe. That is, the source code should be as readable as the executable code, and it should make sense as a recipe.

• If you want an 'A', your recipe must also be coherent enough to be prepared in the real world. This is harder than it sounds.

• Extra credit (5 points) for anyone who brings in a version of their Chef code for us to eat in class.

Page 18: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Hello World in Chef

Hello World Souffle.

This recipe prints the immortal words "Hello world!", in a basically brute force way. It also makes a lot of food for one person.

Ingredients.72 g haricot beans101 eggs108 g lard111 cups oil32 zucchinis119 ml water114 g red salmon100 g dijon mustard33 potatoes

Method.Put potatoes into the mixing bowl. Put dijon mustard into the mixing bowl. Put lard into the mixing

bowl. Put red salmon into the mixing bowl. Put oil into the mixing bowl. Put water into the mixing bowl. Put zucchinis into the mixing bowl. Put oil into the mixing bowl. Put lard into the mixing bowl. Put lard into the mixing bowl. Put eggs into the mixing bowl. Put haricot beans into the mixing bowl. Liquefy contents of the mixing bowl. Pour contents of the mixing bowl into the baking dish.

Serves 1.

Page 19: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

My Sample Chef Program

Danger Flu.

Creates a very dangerous danger flu. Beware!

Ingredients.1 cup yogurt5 g sneeze particulates3 capers4 chives1 level teaspoon chopped parsley1 rosemary sprig

Method.Put yogurt into the mixing bowl. Combine chives. Put capers into the mixing bowl. Add chopped parsley

into the mixing bowl. Pound the chives. Combine sneeze particulates into the mixing bowl. Stir the mixing bowl for 5 minutes. Beat chives until pounded. Remove capers. Liquify contents of the mixing bowl. Pour contents of the mixing bowl into the baking dish. Add capers. Add rosemary sprig. Stir for 2 minutes. Liquify contents of the mixing bowl. Pour contents of the mixing bowl into the baking dish.

Serves 1.

Page 20: The Poetics of Code LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.

Danger Flu.

Creates a very dangerous danger flu. Beware!

Ingredients.1 cup yogurt5 g sneeze particulates3 capers4 chives1 level teaspoon chopped parsley1 rosemary sprig

Method.Put yogurt into the mixing bowl. Stack = 1 Combine chives. Stack = 4Put capers into the mixing bowl. Stack = 3 4 Add chopped parsley into the mixing bowl. Stack = 4 4 Pound the chives.

Combine sneeze particulates into the mixing bowl. Stack = 20 4Stir the mixing bowl for 5 minutes. Stack = 4 20

Beat chives until pounded. Decrement chives, loop until 0 (Stack = 100 100)Remove capers. Stack = 97 100Liquify contents of the mixing bowl. Stack = a dPour contents of the mixing bowl into the baking dish. Stack = a d, Baking Dish = a dAdd capers. Stack = 100 100Add rosemary sprig. Stack = 101 100Stir for 2 minutes. Stack = 100 101Liquify contents of the mixing bowl. Stack = d ePour contents of the mixing bowl into the baking dish. Baking Disk = d e a d

Serves 1. Writes dead to stdout