Conversations with a six-year-old on functional programming (2018)
byorgey.wordpress.com
byorgey.wordpress.com
One Christmas when my whole family got together, I made a "stink detector" which consisted of a USB cable stuck inside a ziplock bag. My nephews were invited to put anybody's sock in the bag, then enter some parameters (like sock color, how long since it was washed, and, crucially, the name of the sock's owner) in a GUI.
Under the hood of the GUI was a grep engine that checked for a whitelist of names and titles ("uncle" among them to be sure), and assigned those names the lowest possible stink number. Whereas my nephews of course were guaranteed to get a high value. That result was fed through a random number generator, to produce a fuzzed-up normal distribution for display on the screen.
They spent a long time varying the parameters, trying to figure out how they affected the "analysis" before figuring out it was all driven by the name.
"I decided to just answer straightforwardly"
That can make all the difference in your interactions with your child and how they learn about this world.
Too many problems are caused by parents not being honest with their kids. Be straightforward, no matter how awkward the explanations may be. Avoid patronizing simplifications and saying things like "you'll understand when you're older". If they're not able to understand or decide they don't want to, they'll stop asking.
and also one of the best ways of improving your own understanding of something is to try explaining it to someone else, and who better than a child? If they say some tradition is stupid or silly, maybe it is! If you can't defend it to them, why do you follow it?
Who knows, maybe you'll even make an unexpected friend to share your interests with. :)
Later, I tried to get a computer to play a simple melody and assumed that 1=A, 2=B, etc. The result sounded wrong, and eventually by trial and error I figured out that if I put C# in place of C, then everything sounded good.
I asked my father why, and he gave me a version of "you'll understand when you're older". My father was a wonderful man, but this is still one of my sadder memories from childhood.
(And which, incidentally, is surely a reason why many parents are finding working from home during quarantine to be so difficult.)
Edit: Point being--scientific accuracy not required. :)
And they'll only stop asking for a very short while (if they're like all the kids I've talked with). Children are people and value honesty and attention like everyone else. If you try, they'll be back.
Plus, I enjoy it even when they don't understand and leave halfway through the answer. They make the best faces to show they're done.
I know _I_ can't, but children seem to be quite good at it.
Another game I play with my kids to introduce the concept of functions which aren't just for numbers is a haircut function. You start by deciding on what the function does (curls hair, cuts it short, makes it longer), write that in the middle of the page, then you draw some input people on the left of the page, and on the right hand side draw the output for each input. Bonus points for running the function twice to see what happens to that person. This is a popular game with my kids and gets them involved as they can draw their own.
It's also fun to go beyond strictly numeric types, eg responding to a number with the name of a country, or turning a letter or word into a number, etc.
The researchers presented the following to people.
f(1) = true
f(2) = true
f(4) = true
f(8) = true
And asked, what is f?And the people will immediately jump in and test 16, 32, and then proudly declare that
f = x -> x = 2^n for some integer n
Forgetting to test f(3), f(5), etc.With more examination it turns out that
f = x -> true.
\* I wish I could remember more of the details such as whether it was an experiment or just an illustration of one but it's not an easy thing to search for and I rely on memory and searching too much.He uses the game to show that people do something akin to Bayesian updating over possible concepts and have certain intuitive priors (e.g., ‘even numbers’ is a priori more likely than {2, 7, 9, 31}).
This is briefly mentioned at the beginning of Kevin Murphy’s Machine Learning: A Probabilistic Approach, so you might also have encountered it there.
A good video and better than I explained it too.
The video says it's inspired by Taleb's Black Swan so I suspect I read it in that too.
I think this mindset should be taught explicitly starting in grade school.
If you have an idea, think how you'd disprove it, and test it. If you can't think of how you'd disprove it, that's a strike against the idea. If you can't test it, that should at least make you suspicious.
Given any input word, I would tell them whether it was above the line, or below the line (which corresponded to acceptable and unacceptable behaviour in camp-speak). I think only two kids figured it out on their own, and each time I challenged them to write a program to categorize words automatically.
I wonder if hacker news can figure it out :)
"Hacker" -> Above the line
"News" -> Above the line
"chrisweekly" -> Below the line
"functional" -> Above the line
"programming" -> Below the line
I think it's called "above the line" "below the line" because the characters in each of the accepted words don't travel below the "character placement line" that runs along the bottom of every word. I've forgotten the "real name" for this line.
Thus,
toothpaste -> below the line, because of "p"
tooth -> above the line, no characters pass below it.
Generally, if the word contains a y,p,q,g, or j, then it's "below".Right?
EDITS:
1: TIL the name for this property of a character is called a descender[1]. (And yet I still can't find the name for that blasted line.)
2: It's called a baseline[2], thanks taylorlunt
REFS:
I'll likely use it to mystify kids someday soon.
let descenders = ['q','y','g','p','j'];
let isBelow = (word) => descenders.some(d => word.includes(d));
let tests = {
"Hacker" : false,
"News" : false,
"chrisweekly" : true,
"programming" : true,
};
for (const test in tests) {
let pass = isBelow(test) == tests[test];
console.log( pass ? `Passed for ${test}` : `Failed for ${test}` );
} data TheLine = Above | Below
categoriseWord :: String -> TheLine
categoriseWord s
| length s <= 10 = Above
| otherwise = Below
There's not a lot to go on, though.Is there a good way to play to train for “most confidence before answering” without making it a drudge of endless tests and humhawing?
Making each question a more powerful test would be good, but that’s not what racing to the answer encourages, that encourages guessing the teacher’s password.
What about tests are free, first to answer wins, but a wrong answer or two disqualifies you completely?
Fuzzy -> Below the line
Weeds -> Above the line
The land of Nodd has floors, but no ceiling. It has grass but no lawn. It has no animals but there are teeth. Etc.
The game is we asked him questions about whether it has something or does not, and we had to figure out what "The land of Nodd" was :P
What about "Hacks"? It uses only letters found in accepted words, but should be rejected because of the odd number of letters.
"Above the line" if len(s) % 2 == 0 else "Below the line"You don’t have to use the official Looney pyramids, of course, but those work really well. Just enough variations to be really interesting.
There’s an older game that uses playing cards, Eleusis: https://en.wikipedia.org/wiki/Eleusis_(card_game)
CGP Grey: The Trouble with Transporters https://www.youtube.com/watch?v=nQHBAdShgYI
Steve Shives: Is Star Trek's Transporter Actually a Murder Machine? https://www.youtube.com/watch?v=f-8zEkIaB0c
> why wouldn’t they just
https://allthetropes.fandom.com/wiki/Story-Breaker_Power
For purpose of storytelling, these powerful side effects of transporters need to be restricted. Hence, as an in-universe explanation, a pattern buffer
∙ is a physical phenomenon that cannot be (fully) expressed as information
∙ deteriorates over time, so needs to be rematerialised soon.
For the exception, see https://memory-alpha.fandom.com/wiki/Relics_(episode)
There are 3 broad cases:
1. Something goes wrong during transport and the person cannot be rematerialised. Typically they end up "stuck" in the pattern buffer of the transporter. Some fiddling and plot tension allows them to complete transport by the end of the episode
2. A partial transport leaves some part of the person behind. This is where you can end up with weird things like piles of sludge on each end, or evil doppelgängers who are mostly the same, but only some features were transported
3. Unknown phenomenon that creates a duplicate. The original has general "failed to transport" experience, while the clone has a complete experience and is so none the wiser that "they" also got left behind.
From this we know that the pattern buffers can absolutely be used to store "backups". This is even discussed at some points after a crew member unexpectedly dies. However what complicates matters is that typically the patterns rapidly lose coherence in the buffers. Whether this happens immediately or after many years is left up to the plot requirements. Generally it seems that unused transporters will hold the last pattern they transported as long as their power supply is stable and are not travelling through space. Anything involving warp, fluctuating power, or transporting other people immediately clears the buffers (and can even cause transporter failures)
The quasi-buddhistic conclusion, with which I agree, is that personal identity is largely an illusion. It's an easy illusion to maintain however, given that in practice our "software" is very difficult to "copy" exactly.
https://en.wikipedia.org/wiki/Reasons_and_Persons#Personal_i...
Like "no, we lost them; maybe they're 'in' the pattern buffers".
To be fair, this is a bit beyond most who had no contact with functional programming and category theory.
Also, there is a strong intuition to free theorems that many people without an FP background will easily understand.
"He gasped in astonishment as I carefully explained the results of the double-slit experiment."
Surely more like that this describes a 6yo kid being excited about something their parent is excited about and a product of implicit empathy, than any significant insight?
I hate to lose reputation with downvotes for sounding negative, but I find my credulity challenged with this story.
Also possible is that what the kid actually understands and what the parent thinks they are understanding are two different things. The kid is quite likely still wrong in some critical way.
But that is where we all start with new things. I've got two boys in 3rd & 5th grade right now and I'm actively fighting with both of them the idea that "learning" is a matter of being told the correct answer and then they forever after know the correct answer in its every nuance. (Not just since the lockdown. It's been a theme for the past six months with me.)
The older one has just started learning Spanish with school... well... nominally with the school, that's actually going very badly, but I started him on Duolingo in the meantime... and that's been a very good doorway into the idea that you can't just be exposed to a single isolated fact once and then have it just magically be internalized, you need to be re-exposed to it over and over, use it, practice it, and discover how your initial impressions were wrong over time.
Could you be swayed to the more optimistic "Education is a series of decreasingly incomplete truths"? I'm a math professor, and we do tend to be able to tell our students the truth, nothing but the truth, but very much not the whole truth, at least in every part of the curriculum that I've seen.
(That we're able to do so doesn't mean no math teachers lie, but it's not as integral—ha!—a part of the curriculum as in physics, say.)
Q. how much is 3 - 5?
A. nothing because you cannot take 5 out of 3.
Q. how much is 2 divided by 3?
A. nothing because you cannot divide 2 by 3.
Q. what are the roots of the quadratic function ...?
A. this quadratic function doesn't have roots because you can't take the square root of a negative number
I believe it's possible to not lie when teaching math, but I guess it's harder to do.
Q. how much is 3 - 5?
A. taking 5 out of 3 does not give a whole-number answer.
Q. how much is 2 divided by 3?
A. dividing 2 by 3 does not give an integer answer.
Q. what are the roots of the quadratic function ...?
A. this quadratic function doesn't have real roots because you can't take a real square root of a negative number
This one is actually true. If someone tells you they have a square root of a negative number, just laugh at them and tell them it's just imaginary.
It's more of a commentary on how humans think and learn, not a judgement on how they teach. I think there's an interesting philosophical debate to be had around whether it's ethical to bootstrap knowledge through a lie, later discarded, if that results in more efficient knowledge transfer than the straight truth.
It's parallel to what I've heard about the trouble with history bring. You just never know exactly where to start.
Mathematics offers an opportunity here that history doesn't: there is a definite starting point, namely, the axioms. Not every course can or should start at the axioms, but it is there as an option, as it isn't with history.
Even so, this point is a very interesting one. I hated history in grade school, but then stumbled upon Shirer's Rise and Fall of the Third Reich while browsing the shelves one day. It hooked me, but made reference to a lot of WWI history that I didn't know, so I started reading about WWI history. But, to understand the antipathies in WWI, you have to go back even further in European history ….
This hunt backwards for first causes has led me to Wilson's Heart of Europe, which traces the history of the Holy Roman Empire. It's a struggle, because it's much more on the scholarly than the popular side of things to which I am accustomed, but I'm engaged in it because it's helping me answer questions that I posed, rather than ones that my history teachers both posed and, all too soon, answered.
I think that the best education, lies or no, is the one that both leaves students asking their own questions, and equips them with the tools to seek out the answers to those questions themselves.
I'd be interested to hear more about that. Standard US undergraduate mathematics curriculums are aggressively non-"the whole truth", but they rarely lie. (Sometimes there'll be less attention than a professional mathematician might like on checking hypotheses, but, in my experience, they're always there for someone who cares to check.) What lies did you feel like you'd been told?
(I mean, of course, content lies. Implicit pedagogical lies like "what you see and do in undergraduate mathematics classes faithfully represents the graduate and research mathematics experience" are unfortunate, and won't go away as long as the audience for math courses is made up much more of people who want to apply it in other disciplines than people who want to be mathematicians, but I think they are of a different character.)
So there is a difference between insisting on being right and acknowledging the possibility of being wrong.
However, this reminds me of the book "Factfulness" where Hans Rosling shows how most of us rely on outdated information (that we were taught decades ago) when asked about the current state of the world. We simply fail to update our knowledge.
The book is highly recommended.
Just because the writing is not up to your standards doesn't mean the kid wasn't astonished when they realized you could put a function in a function. Kids love meta stuff (there's a book my niece & nephew were talking about and they were like "it's so weird!!" -- it was meta)
Also it's not that hard of a concept. Give kids some credit.
Agreed!
> doesn't mean the kid wasn't astonished when they realized you could put a function in a function
This is where my credulity was stretched. It's interesting and exciting when you first learn about it only if it breaks a rule you've long had in your mind and enables you to do more interesting things.
A 6-year-old child hadn't spent years assuming you can't put a function in a function, and they'd have not the slightest idea what you could now do with it.
Generally, very small children have very flexible ideas about the structure and rules of the physical world, so showing them "math tricks" often earns you a, "Duh, of course you can do that!" reaction when you instead expect astonishment. The exception is when they've been doing painful work the slow way and you've given them a shortcut.
It's still a new way of using a new idea. People (including children) pick up all kinds of assumptions along with the information that they obtain. If you describe something with certain examples, and then do something that isn't seen as possible or covered in those examples, that can be very surprising.
Different children are different people and therefore have different expectations and blindspots.
In the last week I have a deal with a friend of mine -- I didn't feel comfortable accepting a gift from him in return for nothing, so I offered to teach him programming. So far, two one-hour sessions later he has a grasp of a lot of the concepts, but the two main things he struggles with are: the environment (i.e. stuff like the command line, etc.), and syntax. I'm teaching him python, in the first one-hour session we learned about variables includings lists and integers, if statements, statements/expressions, and function syntax. We used the second session to refamiliarize some of the syntax for those things, including stuff like telling him about leading whitespace, putting brackets around array indices, and the rest of the time just getting a python file into a folder and getting there in the command line so he could run the file.
He's a very smart person, but his lack of familiarity with the symbol keys on the keyboard, along with the lack of the ability for the command line to cope with spaces in filenames, made it difficult for him.
His main problems aren't knowing how to use the concepts -- he knows what he wants to do -- but the syntax and grammar of the environment constantly get in his way.
Put quotation marks around the file name?
And I think filenames with spaces is a great example of this
If the next time they sit down to do something at the command line they write the equivalent of `cmd "arg 1 arg 2 arg 3"` it should not be surprising, and frustration that it doesn't work as intended should be expected... especially when they're not even trying to learn about their command line in that moment.
Which is perfectly fine. A young child cannot judge by themselve, so they rely on their parent's judgment which is conveyed by emotion.
I played the game an hour ago during family lunch, with my kids aged 15 and nearly 12. It still works!
I upvote.
I don’t want to spoil it, but it’s simultaneously hilarious and a tear jerker. They just replayed it a few weeks ago, you can listen to the climax and conclusion here: https://www.thisamericanlife.org/697/alone-together/act-one-...
My favorite quote of hers was (paraphrasing): "I just wanted someone to talk to."
With regards to your message, I think it's impossible to say whether another person understands something well from reaction. Unfortunately, that is why student focused textbooks (vs. graduate textbooks) usually have a lot of exercises.
Edit: By the way, on a somewhat unrelated topic, I have been told that Lawvere thought that set theory was a "historical error" (these kind of semi-biographical stories are code for trying to explain a mathematician's personality, a futile exercise). I wonder if I'll ever be able to meet him and ask him why he thinks that. (I suspect that it will lead to some Lisptopians becoming excited about objects being immaterial. At which point one should remind Lisptopians not to mix programming the activity with mathematics the activity.) It's ironic that set theory is the best way to learn category theory, at which point you to some extent abandon set theory. Maybe it's the pedagicical value of set theory? I wonder if Lawvere would take all my persistent questions kindly.
This kind of comment is discussed in the second from the last paragraph here:
Is this really the worldview you choose to have?
This is my experience with this community. Downvotes without any discussion on statements (opinion or fact) that exist outside the norm.
My opinion about downvotes is that they reflect way more on reputation of those who actually does the thing (unfortunately they stay anonymous). Well HN rates you using down/up votes but personally since I do not agree with this whole anonymous anti-feature I do not really care.
Alternatively (lets add some conspiracy to spice it up) they might be doing hidden user profiling on whole range of social patterns and sending data to interested parties.
Yes that is what I often observe. As for predictability - it seems to me like anything that deviates from the "party line" (whatever that is for any particular area) gets downvoted. Looks like a usual herd mentality to me.
-- I doubt she knew anything about functional programming back then.
-- It took me 40+ years to get to the universe where this answer was not completely laughable.
-- And meanwhile what 16 y.o. kids were doing at the time, 6 y.o ones are capable of doing now.
ps. Maybe add [2018] to the title?
We inadvertently taught our 2yo something which I think relates to programming. We play an animal-pairs-matching card game, with the twist that if you draw a shark card you can then steal a card off another player (while pretending to be a shark, obviously). Inadvertently my wife and I had taught different rules: I taught that pairs already matched up were safe from the sharks, while she taught that they weren't. So now every game has to start with 2yo deciding what the rules are, which often leads to discussion of consequences for each rule.
Your child might be gifted.
My point being that maybe it's possible to take interest in what the kids like, and use that to teach them something ? With pokémon it could be Statistics, Biology, Storytelling, Programming, etc. Whatever you like :-)
If you restrict the nature of the functions e.g. "polynomials of degree at most d", then the answer depends on the restriction. For the polynomial of degree <= d case the solution is d+1 inputs, every polynomial of degree at most d is uniquely determined by d+1 points.
I vividly recall facetiously making this point, that for all we knew it was the 'number machine' (as I think the teacher called them) that responded 'as described for the inputs shown, and zero for all others', or something; that 'it sure looks like 2x, but we can't possibly know for all numbers'.
If I'd been told the machines were linear I would have learnt something (probably, hard to recall one's knowledge at a specific time) and shut up. Alas, I was sent out...
The teacher put in 0, 30, 60, 90, ... on the x axis and sine (x) on y. Then they began to join them with a beautiful curve. I protested and inquired how we can just join those dots seemingly on faith. The teacher just ignored me in spite of my repeated protests.
I only have vague recollections of numerical analysis, I remembered the Newton-Raphson method (no good: we don't have an oracle for f'(x), just f(x)) and stumbled into the Runge-Kutta Wikipedia page which I'd forgotten about (also no good).
But it seems like a good strategy would be to test one number, guess assuming constant, test a second, guess assuming linear, test a third, guess assuming first order polynomial, and so on.
In the presence of step changes or the like though I suppose there's nothing you can do.
You are still implicitly assuming that the function is continuous. There are a lot of nowhere-continuous functions, e.g. the sawtooth function. Or more interestingly, Conway's base13 function, which takes on every real number in every interval.
Also what about continuous non-polynomials? e.g. exponentials, logarithms, sine/cosine etc.?
> This seemed a bit beyond him [...] But the whole conversation had given me a different idea. "Hey, I have a good idea for a game," I said. [...] He immediately liked this game and it has been a huge hit; he wants to play it all the time.
It's probably made even better by being 'the game that daddy reads about/does at work'.