Lecture 23: Programming with Pictures & Programming Wet Stuff “ToonTalk is a video game for making video games.” David Kahn, age 10. “It's an animated world that lets kids make, run, debug, and trade programs.” Ken Kahn, David's dad CS655: Programming Languages David Evans University of Virginia http://www.cs.virginia.edu/~evans Computer Science Menu • Rotunda Presentations • Non-text based Programming • Amorphous Computing 27 July 2016 University of Virginia CS 655 2 Course Evaluations • You should have received email • Fill out the official evaluation at: http://www.people.virginia.edu/~ad4n/seas_evals/ • Must fill in before May 5 • Once you do, send me email to get the real evaluation – Specific questions like the midterm evaluation – Fill out after the final (this is an important part of the course to evaluate, no matter what SEAS thinks!) 27 July 2016 University of Virginia CS 655 3 Rotunda Presentations • Monday, 6:30 pm • Laptop projector, screen, laptop with PowerPoint – If you need something else, let me know • Not all group members need talk • Aim for about 15 minutes (no more than 20) • Invite guests (but number limited) 27 July 2016 University of Virginia CS 655 4 Giving a Good Rotunda Talk • Pretend its a research conference talk – Your audience knows about the field, but not your specific area – Your goal is to make them want to learn more about your work • A good talk tells a story – Not a collection of slides 27 July 2016 University of Virginia CS 655 5 Beginning • Motivate your work – Convey why the problem you are solving is interesting, important and exciting • It helps when you think so yourself, but act if you don’t – Place your work in context: how is it different from what others have done • Can do this at end instead • Teaser for your results – why should we listen to the rest of the talk? – Don’t need a full outline, but let audience know enough so they want to listen to the rest 27 July 2016 University of Virginia CS 655 6 Middle • Explain your solution – Don’t be comprehensive – convey the big picture – Use pictures, metaphors, examples, etc. to explain what you did • Convey one technical nugget – Show one neat technical thing that came out of your work. Could be: • A surprising example • A design idea • A formalism 27 July 2016 University of Virginia CS 655 7 Last Third • Evaluation – Explain how you evaluated your work – Present your results • Conclude – Summarize your conclusions with one key point 27 July 2016 University of Virginia CS 655 8 Some Specific Advice • Average 2 minutes per slide – Simple slides: big text, use pictures, less words than this slide • Figure out what the most important 1 or 2 sentences in your talk are and memorize them • Practice – I will listen to any group that wants to practice their talk Sunday night; email your preferred time 6pmmidnight. 27 July 2016 University of Virginia CS 655 9 Giving good talks is one of the most important ingredients of a research career. Take advantage of all opportunities you can to practice! 27 July 2016 University of Virginia CS 655 10 Programming • Everything we have seen so far looks identical to my Grandma: – Geeky engineer sits at a keyboard – Types a bunch of cryptic instructions giving step-bystep way of solving a problem 27 July 2016 University of Virginia CS 655 11 Declarative Programming • Prolog (Programmation en Logique) [Colmerauer and Roussel, 1972] – Designed for natural language processing – Used in AI community • Program is a database of facts and inference rules, executes by proving or disproving conjectures • Separates logic from control: – Logic – requirements of a satisfactory answer specified by programmer – Control – how to get it (mostly hidden in interpreted) 27 July 2016 University of Virginia CS 655 12 PROLOG example: facts parentOf (chelsea, bill) parentOf (chelsea, hillary) parentOf (bill, roger) parentOf (bill, virginia) female (chelsea) These may look like female (hillary) function calls, but they are female (virginia) just axioms. male (bill) male (roger) occupationOf (chelsea, student) occupationOf (roger, used_car_salesman) 27 July 2016 University of Virginia CS 655 13 Interactive Session ?- parentOf (chelsea, bill) Yes ?- parentOf (chelsea, roger) No ?- parentOf (chelsea, X) X = bill; X = hillary; 27 July 2016 University of Virginia CS 655 14 Defining Rules • We can define a predicate in terms of other predicates: motherOf (X, M) :parentOf (X, M), female (M) • Read: “M is the motherOf X if M is the parentOf X and M is female.” ?- motherOf (chelsea, Z) Z = hillary; 27 July 2016 University of Virginia CS 655 15 Combining Predicates grandMotherOf (X, G) :parentOf (X, M), motherOf (M, G) ancestorOf (X, A) :- parentOf (X, A) ancestorOf (X, A) :parentOf (X, P), ancestorOf (P, A) 27 July 2016 University of Virginia CS 655 16 Evaluation • Uses unification algorithm like in type inference: guess all possibilities exhaustively ?- ancestorOf (chelsea, X) X = bill; PROLOG specifies rules X = hillary; tried in order. X = roger; X = virginia; 27 July 2016 University of Virginia CS 655 17 PROLOG Factorial factorial (0,1) factorial (N,F) :N > 0, factorial (D, R), D is N - 1, F is N * R. ?- factorial (5, F) F = 120; ?- factorial (N, 27) no 27 July 2016 University of Virginia CS 655 18 Programming by Example • Sometimes called “Programming by Demonstration” • Programmer demonstrates task, system records • Widely used instance: – Word/Excel/PowerPoint Macros 27 July 2016 University of Virginia CS 655 19 Stagecast Creator • Started as KidSim Project, Apple • Before-After Rules: – Guard: predicate to match before invoking rule – Action: sequence of primitive operations Demo at end of class (time permitting) 27 July 2016 University of Virginia CS 655 20 ToonTalk • Provide a video-game metaphor syntax to a regular programming language • Variables = Boxes • Passing Parameters = Birds 27 July 2016 University of Virginia CS 655 21 ToonTalk Metaphors • Comparison = Scale • Robots act like guarded commands – Thought bubble is predicate – Sequence of actions after matching Demo at end of class (time permitting) 27 July 2016 University of Virginia CS 655 22 Visual Programming A favorite subject for PhD dissertations in software engineering is graphical, or visual, programming - the application of computer graphics to software design.... Nothing even convincing, much less exciting, has yet emerged from such efforts. I am persuaded that nothing will. Fred Brooks, 1987 27 July 2016 University of Virginia CS 655 23 Amorphous Computing Cement 10 GFlop 27 July 2016 University of Virginia CS 655 24 Premise • Will soon be cheap to make lots of computational stuff so long as: – It doesn’t all have to work correctly – Arrangements and interconnects are mushy • Examples: – Construct logic circuits using biological cells – Nanotechnology • How to you program it? – Get acceptable answers with high probability – Look to biology for inspiration and metaphors • Human genome: 3 Billion base pairs = 750 MB 27 July 2016 University of Virginia CS 655 25 Model • Computing elements sprinkled on a surface or in a volume • Each can talk to a few nearby neighbors, but not reliably • Each has modest computing power and a modest amount of memory • The particles are not synchonized, nor are they regularly arranged. 27 July 2016 University of Virginia CS 655 26 Slide adapted from Abelson/Knight/Sussman talk Why is this interesting? • • • • Physically feasible at any scale Forces robustness of design Potentially extremely inexpensive Provides the possibility of bulk computation – smart paints – smart gels – concrete by the Megaflops 27 July 2016 University of Virginia CS 655 27 Slide adapted from Abelson/Knight/Sussman talk Amorphous Computing Medium An amorphous medium has independent computational particles, all identically programmed. Each particle is represented by a spot in the picture, and different states are shown by different colors. 27 July 2016 University of Virginia CS 655 28 Biological Programming • Growing-Point Language [Coore99] • Two primitive datatypes: – Materials – colored stuff that can be left in amorphous medium – Pheromones – chemicals that attract or repel other growing points, spread out diffusely when secreted • Growing points may split, die, merge 27 July 2016 University of Virginia CS 655 29 Growing Point Program (define-growing-point (A-to-B-segment) (material A-material) What is deposited as it grows (tropism (ortho+ B-pheromone)) Grows towards increasing quantities of B-pheromone. (actions (when ((sensing? B-material) Stop when touching B-material. (terminate)) (default (propagate))))) 27 July 2016 University of Virginia CS 655 30 Growing Point Program (define-growing-point (B-point) (material B-material) What is deposited as it grows No tropism – it is stationary. (for-each-step (secrete 10 B-pheromone))) Distribute B-pheromone to neighbors, radiates approximately symmetrically, decreasing over 10 units. 27 July 2016 University of Virginia CS 655 31 Slide adapted from Abelson/Knight/Sussman talk Start with Vdd, Vss, and a Poly Contact 27 July 2016 University of Virginia CS 655 32 Slide adapted from Abelson/Knight/Sussman talk The poly contact sprouts a growing point that bifurcates and then grows toward the pheromones secreted by Vdd and Vss. 27 July 2016 University of Virginia CS 655 33 Slide adapted from Abelson/Knight/Sussman talk When the growing poly gets close to Vdd and Vss it is stopped by a short-range inhibition 27 July 2016 University of Virginia CS 655 34 Slide adapted from Abelson/Knight/Sussman talk The poly growing points die off, but first they sprout P and N transistor diffusion growing points, which grow toward Vdd and Vss, where they drop contacts. 27 July 2016 University of Virginia CS 655 35 Slide adapted from Abelson/Knight/Sussman talk The diffusions also grow toward each other. When they hit they form a new poly contact and poly growing point. 27 July 2016 University of Virginia CS 655 36 Slide adapted from Abelson/Knight/Sussman talk The process then repeats, growing the next inverter. 27 July 2016 University of Virginia CS 655 37 Slide adapted from Abelson/Knight/Sussman talk This process repeats to make an arbitrarily long chain of ugly, but topologically correct inverters. This demonstrates totally local control of precision topology. 27 July 2016 University of Virginia CS 655 38 Slide adapted from Abelson/Knight/Sussman talk (define-growing-point ((poly from-input-contact) Q-id) (material poly) (tropism constant Vdd-long Vss-long) (initialize lifetime 5) (secrete (poly-short inhibitor) Q-id) (when (= lifetime 0) (start-growing-point (poly up) Q-id) (start-growing-point (poly down) Q-id) (terminate))) 27 July 2016 University of Virginia CS 655 39 Amorphous Computing Summary • If you have enough randomly-distributed amorphous stuff, can use GPL to produce any topology • We can build arbitrary logic out of biological stuff (DNA, RNA) – Once you can make an inverter, can program anything 27 July 2016 University of Virginia CS 655 40 Which of PROLOG, ToonTalk, Creator, GPLs are Programming Languages? 27 July 2016 University of Virginia CS 655 41 What is a language? (Lecture 1) Nerdy Linguist’s Definition of Language: A description of pairs (S, M), where S stands for sound, or any kind of surface forms, and M stands for meaning. A theory of language must specify the properties of S and M, and how they are related. Liberal Definition of Programming Language: A language (according to the nerdy linguist’s definition) intended to be read and written by humans and processed by machines. 27 July 2016 University of Virginia CS 655 42 From Lecture 2: • Bruce MacLellan’s definition: A language that is intended for the expression of computer programs and that is capable of expressing any computer program. • Ravi Sethi’s definition: Notations used for specifying, organizing, and reasoning about computations. 27 July 2016 University of Virginia CS 655 43 Charge • Tomorrow, 11:59pm – Project Reports due • Monday night: Rotunda Presentations • Next time: Jeopardy (in your project teams) 27 July 2016 University of Virginia CS 655 44