Hacker News new | past | comments | ask | show | jobs | submit login
Conversations with a six-year-old on functional programming (2018) (byorgey.wordpress.com)
580 points by _ttg on April 22, 2020 | hide | past | favorite | 155 comments



\lambda x. 6 was also surprisingly difficult for him to guess... It simply hadn’t occurred to him that the machine might not care about the input.

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.


Now that would have been fun to watch. Nicely done!


The most key point of this is right at the start:

"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. :)


I remember, when I was a kid, that I had a toy piano where the notes C, D, E, etc. were labeled 1, 2, 3, etc.

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.


You may have asked him at the worst possible time for him personally. Whyever he didn't explain it at the time, I'm sure it's nothing to do with his love for you.


Oh, no question about that. When I was a kid, I tended to assume that my parents always were available to drop what they're doing and engage with you.

(And which, incidentally, is surely a reason why many parents are finding working from home during quarantine to be so difficult.)


Your question may have touched a nerve, if he was getting older and no longer could see sharp.


Or he just wanted to be flat on the couch, without being disturbed.


Maybe he was like me who had some degree of hearing loss when I grew older and could no longer hear C sharp.


musical notes repeat once every doubling of frequencies, so there are many C#s spread throughout the range of human hearing. The only way someone could be unable to hear c# would be if they were unable to hear at all.


Your parent and grandparent comments were (imo, clever) word plays on C# / see sharp and back to _hear_ c# (instead of see sharp).

Edit: Point being--scientific accuracy not required. :)


oops!


>If they're not able to understand or decide they don't want to, they'll stop asking.

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.


Parents observe their child learn the most in-depth actions and knowledge from a dizzying array of input...and then too often decide that children can't handle nuance or depth.

I know _I_ can't, but children seem to be quite good at it.


Definitely great advice! I have always felt the same with my kids. Be honest and try to answer your best even if you know they won't fully understand.


I find kids understand the concept of functions really intuitively if it is stated simply - input -> func -> output, it doesn't have to be difficult maths, and it can make for some great games. It looks a little intimidating if using the notation in this article but they easily grasp that a function transforms inputs and returns outputs, and it can be a fun introduction to maths and programming, and then later to things like graphs based on functions.

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.


Agreed! My kids are slightly older but we've long enjoyed a roadtrip game that's a variation on 20 questions: "give me an input, I'll respond with an output, then you guess what the 'machine' [algorithm|function] did". They'd get to provide one input, I'd respond w one output, then they'd get one chance to define the operation -- to which I'd respond only yes or no -- before the next person's turn to test it. Whoever solves it gets a point (if we're keeping score; not important). Then the next person gets to be the function maker. They got pretty good at hypothesizing plausible solutions and refining them to hone in on the precise answer, and it was more interesting than standard 20 questions.

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.


This reminds me of a prediction game experiment I heard that was described like the following. \*

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.


Something like this is in Josh Tannenbaum’s PhD thesis, where he calls it “The Numbers Game.” https://dspace.mit.edu/handle/1721.1/16714

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.


Sounds a lot like Derek Muller’s (Veritasium) video:

https://youtube.com/watch?v=vKA4w2O61Xo


Thanks, that's it!

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.


a similar thing happens with folks when debugging. They assume something, and test their assumption and can happily declare victory. Instead, they should be testing _against_ their assumptions to prove their theory wrong.


> Instead, they should be testing _against_ their assumptions to prove their theory wrong.

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.


In theory, that's the scientific method, but aomehwt we've evolving this weird grade school science project "scientificky" method in it's place.


I taught at a programming camp one summer, and my favourite example of this that I drove several kids crazy with was "above the line, below the line".

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


(Spoiler?)

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:

[1] https://www.merriam-webster.com/dictionary/descender

[2] https://typedecon.com/blogs/type-glossary/baseline/


This is the right answer! I think it was made harder in the camp due to "above the line" and "below the line" already having semantic meaning in the context of the camp, most kids didn't expect that to literally be the answer.


yeah that makes sense, thanks for sharing it with us!

I'll likely use it to mystify kids someday soon.


That reminds me of “green glass door” and what you can and can’t take with you to magic land through the door.


The line is called a baseline.


Thanks :)


    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}` );
    }


Ding ding ding. You get extra camp tickets for adding tests :)


Rather depends what font the quizmaster is speaking in: https://graphicdesign.stackexchange.com/questions/71807/what...


Ha, yes, and what language. My example won’t work for ŷ and any others like it.


Just a guess:

    data TheLine = Above | Below

    categoriseWord :: String -> TheLine
    categoriseWord s
      | length s <= 10 = Above
      | otherwise      = Below
There's not a lot to go on, though.


There is a similar game that goes like "The king does not like tea but he does like coffee". The you can ask questions like "Does he like cookies?" (answer: yes), "Does he like cats?" (answer: no)


Curious that the way we play these games is “race to the answer” in fewest tests, and as soon as someone else gets it, the game is over and spoiled for anyone who didn’t.

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?


Words go below the line iff they contain the same letter twice in a row


Been -> Above the line

Fuzzy -> Below the line

Weeds -> Above the line


In college a friend had about 10 of us dumbfounded for an hour as we tried to figure out what "The land of Nodd" was.

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


I'm guessing Nodd has a lot of bookkeepers!


I'm taking this comment as evidence that I've succeeded in figuring it out.


We used to play a game in summer camp where one had two sticks and could hand them to the next person 'crossed' or 'uncrossed' declaring as such. The key was it was the persons legs, not the sticks, which determined if one was passing the sticks 'crossed' or 'uncrossed'.


Current list of words is consistent with "has an even number of letters".

What about "Hacks"? It uses only letters found in accepted words, but should be rejected because of the odd number of letters.


Check for odd or even string length?

  "Above the line" if len(s) % 2 == 0 else "Below the line"


Awesome version of 20 questions. My parents are biologists and we played 20 questions with plants/animals on road trips growing up. The games were intense! Learned a ton.


Did anyone ever just try and search through a phylogenetic tree?


Basically yes, that is what the games evolved in to.


I remember a friend pranking other friends, the quizmaster would rotate his pair of hands palm up or palm down and the victim had to guess either "opened" or "closed". Slowly the kids would get it after a few steps, frustrating the "main" victim of the prank. In the end it turned out the state was whether the quizmaster left his arms pressed against his body (closed) or a few inches "opened". A variant would be whether he'd leave his lips pressed together or slightly apart...


For a non-road-trip version of this idea, check out Zendo: http://www.koryheath.com/zendo/

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)


I sure hope the haircut function mutates it's input, and doesn't return a clone whose hair is cut.


Reminds me of a YouTube video which said every time someone gets beamed in Star Trek they are killed and someone else is created with their body and mind somehow. If that were possible, why wouldn’t they just store backups and “restore” from backup when someone died?


> a YouTube video

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)


This is something that is addressed in the show! Pulling all my knowledge from just TOS and TNG;

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)


There's a notable book by philosopher Derek Parfit called "Reasons and Persons" that—among other things—uses "transporter" thought experiments to explore the nature of personal identity.

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...


A type of restoring from backup, well the short-term pattern buffer memory, has been a feature of several "transporter" episodes I think?

Like "no, we lost them; maybe they're 'in' the pattern buffers".


;)


The way maths is taught in Australia, for a long time the term function was synonymous with the concept "2D plot that passes the vertical line test" in my mind. I was completely unaware of how much broader and more interesting a concept functions are. There are probably many people whose understanding never progresses beyond this, which I think this is extremely unfortunate.


For what it's worth, this intuition is sound and I think it works just as well if you formalize[1] it to be used to illustrate the lambda calculus.

[1] http://dkeenan.com/Lambda/


>> a free theorem is when you can say something that is always true about a function machine if you only know its type, but you don’t know anything about what it does on the inside.” This seemed a bit beyond him...

To be fair, this is a bit beyond most who had no contact with functional programming and category theory.


Has nothing to do with category theory. Not necessarily at least.

Also, there is a strong intuition to free theorems that many people without an FP background will easily understand.


"He gasped in astonishment at the idea of putting function machines into function machines"

"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.


"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?"

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.


Education is a series of increasingly smaller lies


> Education is a series of increasingly smaller lies

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.)


In my school, I was lied to by teachers instead of just saying "we will get to that later" or something. For example:

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.


To be fair, this is not a lie. The teachers were unknowingly giving you a Type-Theoretic answer. The answer to your questions change dependent on the Number Type you are calculating with. :)


To be sure, there is a habit to make the teacher's life easier by lying, and I certainly believe you when you say that you were lied to; but all of these can be rescued, as a sequence of decreasingly incomplete truths, just by adding quantifiers. Since the human brain is (excessively) good at ignoring quantifiers, a skilled teacher (not me, in this context—I'm a college teacher, so am not claiming that this is the right language for primary schoolers, just that it's true) can speak truthfully without impairing the pedagogy:

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


> 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.


This was certainly meant to toe the line, but mostly tongue in cheek. I don't attribute malice to educators. I respect the hell out of the good ones. But at the very least, lies of omission are common.

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.


> 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 think that the optimism comes from you're the one telling the incomplete truths or lies and not the one hearing them. when i was in graduate school for mathematics, it indeed felt that i had been lied to in undergraduate school. also, i think people are being a bit facetious when they say lie as well, but there's a kernel of truth to it.


> when i was in graduate school for mathematics, it indeed felt that i had been lied to in undergraduate school.

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.)


Physics education is learning the simple harmonic oscillator with increasing levels of sophistication


> A lie-to-children (plural lies-to-children) is a simplified explanation of technical or complex subjects as a teaching method for children and laypeople. The technique has been incorporated by academics within the fields of biology, evolution, bioinformatics and the social sciences. It is closely related to the philosophical concept known as Wittgenstein's ladder.

https://en.wikipedia.org/wiki/Lie-to-children


> 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.

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.


I think he goes further than that: even young people have outdated knowledge in accordance with some predictable biases. We rely on the information because it fits some narrative we believe about the world, not because we learnt it when it was correct 30 years ago.


These concepts -- at the level of detail described in the article -- are well within the grasp of a bright six year old.


I’d be willing to bet you could, for example, explain to a smart 6 year old what the “composition machine” or the “inversion machine” does.


I'm not going to downvote you but this is pretty joyless

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.


> Kids love meta stuff

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.


> 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.

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.


This. Programming isn't difficult, you can teach it to an adult in a one-week course and I've taught the fundamentals (if statements, functions, loops) in a two hour session with multiple adolescent friends, the core concepts are mostly intuitive for anyone with a simple grasp of logic. What is difficult is using those systems to understand larger systems, and all of the other crap that comes in programming.

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.


> along with the lack of the ability for the command line to cope with spaces in filenames

Put quotation marks around the file name?


It's hard for people new to programming or talking to a computer to understand how to be precise enough

And I think filenames with spaces is a great example of this


sure, it's an easy fix, but it's one more hurdle to jump across.


Exactly. And when the inevitable "but why?" comes, you can either say "don't worry about it for now, magic" (disempowering) or explain the actual reason why...when you have lots of these little segues simple tasks and simple concepts become suddenly complex. There's a lot to take in, and although the fix is simple, it's yet one more thing to hold onto that can be imprecisely remembered.

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.


Do you recall the name of the book?


Story Thieves: The Stolen Chapters


That the child was able to access insights into something new is dimmed in no way by your causal understanding of implicit empathy. This is partly a failure of the writer to convey with precision, what the kid went through in that exact moment. That the kid was genuinely receptive towards the subject because his dad is into it has little bearing on the micro-epiphany he must have gone through. If only we could all retain that sense of wonder with age.


> 6yo kid being excited about something their parent is excited about and a product of implicit empathy, than any significant insight?

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.


This reminds me of one of my favorite stories in This American Life, about a very young daughter who has a lot of questions, and her dad (a professor) asks her to write them down. She comes to him with a list with questions like “are we alive? Explain.”

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-...


This is a great episode.

My favorite quote of hers was (paraphrasing): "I just wanted someone to talk to."


I mean, 6 year olds get excited about all sorts of learning because their proper teachers are enthusiastic. But that enthusiasm helps them enjoy learning real things. And the concepts in the blog post aren't much more complicated than the other fundamentals children learn at that age. So like learning addition and reading, it's probably both the excitement of learning and the mirroring of their teacher.


Wait, how do you get from function spaces to the double-slit experiment? Or is it just for illustration of two moments...

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.


>I hate to lose reputation with downvotes for sounding negative

This kind of comment is discussed in the second from the last paragraph here:

https://news.ycombinator.com/newsguidelines.html


Either that or this is a blog post about `Things that didn't happen.`. If OP is claiming a 6 years old understands what `He gasped in astonishment at the idea of putting function machines into function machines` means then he is lying.


Why is it so hard to fathom? I'm pretty far from smart but I understood functions at that age, and going a few steps further is not that hard. Besides, this is a child of a brilliant CS professor we're talking about, not your average kid.


As a parent, I can tell you with 100% certainty that kids can get this kind of concept.


Nothing ever happens. Everything is fake. People regularly lie about even the most banal things because everyone is a compulsive liar.

Is this really the worldview you choose to have?


"He cried when I told him about typeclasses and monads"


>I hate to lose reputation with downvotes for sounding negative

This is my experience with this community. Downvotes without any discussion on statements (opinion or fact) that exist outside the norm.


Even more so if you make it meta like you just did, watch this!


"I hate to lose reputation with downvotes for sounding negative, but I find my credulity challenged with this story."

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.


I've found HN to be incredibly unpredictable when it comes to public opinion. I've had comments start out with a dozen up votes only to sink into the negatives hours later, and comments that spent a day at negative four suddenly rise into the positives.


Positive sinking into negatives...

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 was 16 and learning FORTRAN at school. I was a lazy bum at that time (well, that stayed ;-), didn't really prepare, and at the final exam, the teacher asked me in what order the program is executed. Not knowing any better I replied "a value is calculated when the rest of the code needs it" (like in regular math that we did a lot at the time too). She said "not correct, it executes in the order it is written".

-- 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.


It looks like you projected your own laziness onto the language.


Fun fact about fortran: its creator (John Backus) was fond of functional programming, but that was after the fortran creation.


Thanks _ttg for posting this! I just spent an hour with my 5-year old going over all the functions mentioned in the post and then some. I would give him an 'x' and he returned f(x) to me. Eventually we ended up at Collatz Conjecture and he absolutely loved it. I've always wanted to explain that one to him but it was hard to simplify the concept. Starting with simpler f(x) and building up to comparisons like min/max worked out perfectly. He completed the entire chain of 7 on his own! Thank you :)


I remember the first time this was posted, almost 2 years ago. I've played the functional machine game with my daugther (then 6) a lot since, and she still at times ask if we should play! It's such a good way to make things like these interesting. Thank you!

ps. Maybe add [2018] to the title?


I will try to remember this in a few years time!

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.


...it gets better! this morning she brought her doll to the game, and we had to draw cards and play on dolly's behalf too...


My seven year old would glaze over somewhere in the first sentence and switch topics to Pokemon.

Your child might be gifted.


To quote the traditional meme on Pokémon: https://9gag.com/gag/534844/serious-pokemon-math

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 :-)


Nobody will remember that nerd, though. Now, your kid...your kid's name will be echoed in the halls of Gym Leaders worldwide.


I did the same to be honest.


Ive always thought an under appreciated point in this story is the word “machine”. A function doesn’t mean anything to a kid, but a machine is so easy to visualize and understand. I’d imagine that with calling it a function “machine” it would be much harder to understand, since you can’t imagine a factory doing work to an input to get an output with the word machine.


Surprising because I have seen few 6 years olds can do multiplications and divisions. If I'm not mistaken, standard US 1st grade curriculum expects kids to be familier with only addition below 100 and subtraction in low teens.


The specific examples are with factors 2 and 10, most kids can handle those earlier.


My kid took an evaluation test in elementary school to see what they already knew. He hadn't been taught long division yet, but when he was presented with the problem he figured it out on the spot. The teacher thought that was remarkable enough to bring to my wife's attention.


Some people get it earlier. Some people never really get it.


Kids definitely can grasp this on a very tangible level. I just explained function input and output to my 8yr old and she immediately said "Oh so like food is input and poop is output!" Yes we are all functions!


Golden response - bright future in programming for her.


I had a fun conversation with my 6yo about recursion (or is it encapsulation?). We were out of green Play-doh so she came up with the idea to pretend blue Play-doh is green and to make a lump of green Play-doh out of the blue. When I suggested we can telescope this she spent the whole day saying sentences like "X made out of <p1> made out of <p2> made out of <p3>....". Was cool to see how tickled she was by the idea.


This kid is going to be so much better of in life in a STEM field than his peers without a parent who teaches functional programming/theory courses and as one that takes an interest in their children (which I am sure most, of not all, parents do). I say this because reading the story helped me see that I should do this when I have kids: expose them early on to what I’m doing and help them get ahead anyway I can (if they so choose a STEM aligned career they’ll be advantaged some) but also wishing I had parents that finished college so they could do this for me. They didn’t and I made it out okay so I’ll just better the next generation where I can. What a cool post. And that kid sounds really smart. I bet he’s going to go on to do big things.


My daughter was in kindergarten when I first read this a few years ago. She loves the “guess what the function does” game.


So nice! This morning my 7 y/o son said the epic words: I really know a lot, I think about 50% of all there is. Naturally triggered and with Dunning-kruger in the back of my mind I start explaining about how he knows about rain, but not about molecules and exactly why it falls down and that generally smart and knowledgeable people realize that there is still a lot they don't know and that it is a sign of deeply understanding something if you realize it. But I was wrong he said, because he saw a movie about rain during his (home schooling) curriculum...


What's the optimal strategy for choosing inputs in order to guess the nature of the machine?


I don't think that this problem is even computable, since the functions could be arbitrarily complex.

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'm having flashbacks to middle school when this was a (childish and easy, I thought, because we were 12 or whatever, not 6) exercise in a maths lesson.

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...


I had a similar experience in eighth grade with introduction to trigonometry.

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.


Sure, but it's bounded by human creativity, and there's anyway a difference between reliably and deterministically computing the function, and a sort of approximation with repeated guesses, or reaching a certain confidence.

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.


> 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.

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.?


If the functions are restricted to polynomials with non-negative integer coefficients, you only need 2 inputs regardless of degree. Proof left as an exercise to the reader.


Interesting question. If you have a prior distribution for the space of possible functions, you can find the input that minimizes the entropy of the posterior distribution (ie. makes it more like a delta and less like a uniform distribution)


I wanted to argue imps, dwarfs and other types of programs when I noticed that I was applying core wars terminology to a completely non core wars problem...


Such a beautiful story about love and passion. Thank you for sharing this inspiring annecdote !



I remember having these kinds of games all the time in middle school in France. They also were called "machines" at the time.


(2018)


146


Maybe we should let kids be kids and do kids stuff instead?


This is the very definition of kids stuff. Kids stuff = stuff kids find interesting and stimulating.


what by ignoring their questions? the difference between engaging with their curiosity and forcing stuff on them is... not at all nuanced, really.


The question of the kid was legit, but the "a free theorem is when you can say something that is always true about a function machine if you only know its type, but you don’t know anything about what it does on the inside" is likely not what he asked for.


The author acknowledged that was a bit much and pivoted it to a game that his son loves, who put you in charge of taking that away from him?

> 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'.


Fair, tbh it may not have been needed, but I also struggle with letting go the original question asked even though the child may have moved on! Still, this example is hardly robbing anyone of their childhood.


Kids stuff like staying up all night playing Factorio!


Playing games with them they seem to enjoy isn't kids stuff?


That IS "kid stuff". Playing around with ideas (as well as with physical objects) is exactly what kids do. And it's fun!


Kill the Heritic!


I see a lot of articles that try to make FP look really easy. The majority of programmers have a lot of trouble figuring out how to figure out a typical FP program with its layers of nested functions. It isn't easy, which is why most code bases are not FP.


You should watch Rich Hickey's "Simple made easy", to understand why "easy" is almost never better than "simple". FP programs are almost always simpler than similar OOP programs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: