This message was in a conversation but I think the...
# thinking-together
m
This message was in a conversation but I think the topic (and the resources linked) are good for a thread on its own. What do you think of programming by example and programming by demonstration? what's the best implementation/resource/talk you have seen?
🙌 3
k
j
I really love the idea of programming by example. It seems that for many of the things I find myself doing day to day, it ought to be possible to have a computer infer what I am doing. I do think our current approaches make this incredibly hard. One really cool attempt at it is Barliman by Will Byrd. Having played with it, it is definitely not something you’d want to use in practice, but still really neat.

https://www.youtube.com/watch?v=er_lLvkklsk

(Shameless self promotion) I also talk a bit about programming by example at the end of my talk on meander:

https://www.youtube.com/watch?v=9fhnJpCgtUw&feature=youtu.be&t=2108

I never continued exploring this avenue, but the approach worked for quite a few more examples than I showed and I think could be extended quite a bit.
j
I feel like the examples mentioned so far, while sharing some kind of kinship, have a different flavor from the old research I mentioned above. Here's an example video from 1994 in the context of charting data:

https://www.youtube.com/watch?v=jiHRCtJCRts

Or a system that offers these interactions that resemble Perlin's ChalkTalk to develop UIs (25 years ago):

https://www.youtube.com/watch?v=VLQcW6SpJ88&list=PL3856C8FlIWfr_tX8CMUhOJvl34ylClgb

One of my favorite systems from this period was Peridot (plus Garnet, &c -- all the "gemstone" systems that team made), but the only video I can find very low resolution, which often makes it hard to read the onscreen text:

https://www.youtube.com/watch?v=FsGx7G72V0Q

a
What is the fundamental difference between TDD and coding by example? Does coding by example just mean every variable has a default value? Or is it deeper than that?
j
@Andrew Carr This is not "coding by example" but "programming by example" — that is it's not just a matter of having example values in the code or starting with input/output pairs, but rather a different way of communicating your intent to the computer (often graphically rather than textually). I recommend you watch the

charting example video

above to get a sense for it.
👍 1
j
@Andrew Carr
What is the fundamental difference between TDD and coding by example?
To put things a different way, TDD is about a human providing examples and then a human coding to make those examples work. Programming by example is about allowing a human to provide example and then the program is automatically derived from that example. More in line with what @Jack Rusher is talking about is this section from Bret Victor’s magic ink that goes into more in depth with an example. http://worrydream.com/MagicInk/#designing_a_design_tool In fact in this essay, there is a quote that relates the kinds of things Jack talked about to the kinds of things I was discussing.
Many systems attempt to infer a full computational procedure, and have the most difficulty with computational concepts such as conditionals and iteration. As we will see, this tool mostly has to infer mappings from some set or numerical range to another—functions in the mathematical sense rather than the (imperative) computational sense. This may be significantly easier.
Barliman is a system that tries to infer full computational procedure. The systems Jack is talking about are much more inline with what Bret is achieving, inferring particular relations given a graphical input. The point of my example in my talk is that there might be some way in which we can take ourselves much further into inferring from examples to computational procedures, by changing up our programming models. I absolutely love the work that Jack linked, but I would love to see programming by example become a more general technique useful beyond domain specific cases and with some nice underlying model that can be broadly applied. In other words, I just want to work from the ground up to get something that can power the various awesome projects that Jack posted without having to code those interactions specifically.
❤️ 4
a
Ah! Thank you. That's much more clear. It almost feels like the end goal of some of the current parametric learning work (e.g., deep learning) where you give a single example and can generate/extrapolate to a functioning program. Love it. I look forward to watching and reading more this afternoon.
❤️ 1
j
@Jimmy Miller For the record, I'm also a Barliman superfan. 🙂 We've talked with Byrd a bit about getting something similar working for a subset of Clojure in Maria.cloud as part of a learner's assistant. I've already added a
suggest
function that does this weaker but still potentially useful "suggest possible code based on a before/after pair":
Copy code
(suggest [1 2 3 4] :=> 1)
;; (("first" [1 2 3 4]))

(suggest [1 2 3 4] :=> 4)
;; ((last [1 2 3 4])
;;  (peek [1 2 3 4])
;;  (count [1 2 3 4]))

(suggest [1 2 3 4] :=> [2 3 4])
;; ((rest [1 2 3 4]))

(suggest [1 2 3 4] 3 :=> [2 3 4])
;; ((rest [1 2 3 4])
;;  (take-last 3 [1 2 3 4]))

(suggest [1 2 3 4] 1 :=> 2)
;; ((second [1 2 3 4])
;;  (nth [1 2 3 4] 1)
;;  (get [1 2 3 4] 1))

(suggest 1 [1 2 3 4] :=> [2 3 4])
;; ((rest [1 2 3 4])
;;  (drop 1 [1 2 3 4]))
❤️ 3
This is a much better resolution video showing a good flavor of the work (drawing interface instead of coding them, using inference to guess the user's intent and asking for confirmation, constraint-based layout systems, and so on):

https://www.youtube.com/watch?v=wc8A0woo0X4