2014/09/15 09:00 Cristina Videiera Lopes, “Exercises in Programming Style”, PLoP 2014

2014/09/15 09:00 Cristina Videiera Lopes, “Exercises in Programming Style”, PLoP 2014

Plenary address @cristalopes at Pattern Languages of Programs 2014, Allerton Park Retreat Centre, Monticello, Illinois

This digest was created in real-time during the meeting, based on the speaker’s presentation(s) and comments from the audience. The content should not be viewed as an official transcript of the meeting, but only as an interpretation by a single individual. Lapses, grammatical errors, and typing mistakes may not have been corrected. Questions about content should be directed to the originator. The digest has been made available for purposes of scholarship, posted by David Ing.

About 20 participant in the room, laid out classroom style with a large screen projector


Icons:  Art History, Simplified

  • Can recognize Dali style paintings

Have programming styles

  • Ways of expressing tasks
  • Fractal, see in programs, organization, all scales
  • Frozen in programming languages, sense of convention in syntax, forcing people to think in a way:  programming paradigms

Teaching advanced programming, students have a shallow understanding based in the languages they learned

  • How to teach?

Raymond Queneau, Exercises in Style

  • Starts with trivial stories, tells 99 versions of the same story
  • Inquisitive approach, dreamy approach, etc.
  • Gives titles to each style, maybe not translated in the best way from the original French

Oulipo’s styles

  • Based on constraints, that generate creativity
  • To start from the blank page, start from a constraint
  • “A Void” (La Disparition) by Georges Perec:  has a feeling like something is missing, it doesn’t use the letter “e”, so can’t use the natural word

Computational approach, term frequency

  • Eliminate words like software
  • Normalize to lower case
  • List more frequently-occurring words
  • e.g. Pride and Prejudice, mr 796, elizabeth 6358, very 488, darcy 418

First named as style #1, etc., because would get attacked on name, then put the names back in publishing the book

Example with lots of ifs: what are the constraints?

  • No abstraction
  • No use of library functions
  • Monolithic style
  • Diagram:  control flow is overbearing
  • The language was Python, but would have the same constraints in Java

Style #2, 6 lines of code

  • Code golf style, either fewest lines or fewest characters, comes from APL
  • As few lines of code of possible
  • “Try Hard”

Style #3: 1.5 pages

  • Procedural abstraction
  • Shared state
  • Series of commands
  • Cook book style:  first sugar, then add other ingredients

Style #4 seems almost identical, but different

  • Functional abstraction, think in terms of math
  • No shared state
  • Functional composition f o g
  • Pipeline style, chain one thing after the other (a fixed pipeline)

Style #5

  • Like Javascript and Node, a functional form of goto
  • Functions take one additional parameter, f, call at the end
  • Kick forward style

Style #6

  • Things, things and more things, capsules of data and procedures
  • Data is never accessed directly
  • Capsules can reappropriate procedures from other capsules
  • Kingdom of nouns style

Style #7

  • Similar to #6
  • Capsules receives messages via single receiving procedure

Style #8:  concurrency

  • Like Mapreduce, can parallelize
  • Hadoop has another map on the reduce function, then have many partial solutions
  • Two key abstractions, mapping of chunks and reducing to results

Style #9:  not just counting words, extract more knowledge

  • Entities and relations between them
  • Query engine, with declarative queries
  • Persistent table style

Take aways:

  • There are many ways to solve problems
  • Constraints are important for communication
  • Don’t be a hostage of one way of doing things