Live data from Hacker News

Conversations with a six-year-old on functional programming

byorgey.wordpress.com

11–20 of 319 posts

Re: Conversations with a six-year-old on functional programming

#11
post #4
post #2

>\lambda x.\, 6 was also surprisingly difficult for him to guess (though he did get it right eventually). I think he was just stuck on the idea of the function doing something arithmetical to the input, and was having trouble coming up with some sort of arithmetic procedure which would result in 6 no matter what you put in! It simply hadn’t occurred to him that the machine might not care about the input. (Interesting…

I'm curious what you mean. Is the problem that it is a constant function, or that you are asking them to ignore parameters? Or is that missing the point, still?

A function with a linear type uses it's parameters exactly once. The concept of "linear type" doesn't relate to a the concept of "linear function" except in an abstract mathematical way.

Re: Conversations with a six-year-old on functional programming

#14
When my son was around five or six, I did a similar exercise to explain the difference between prime and composite numbers.

I told him that a number X is composite if you can fit X apples into buckets and end up with the same number of apples in each bucket.

I drew 6 apples and asked whether they could be divided into buckets with an equal number of apples in each. It was immediately obvious that they could. My son circled one group of three apples, then another group of three apples.

Then I drew 7 apples. He realized that you couldn't divide 7 apples into baskets and have each basket contain the same number of apples.

Voila! A prime number.

Then we started talking about the frequency with which prime numbers occur on the number line, how important they are to fields such as cryptography, and the existence of dense Bragg peaks among primes in judiciously chosen intervals. By the end of the conversation, he had discovered a new recursive prime generator and submitted a paper on it to arXiv. Who knew?!?

Re: Conversations with a six-year-old on functional programming

#15
post #3

What is truly astounding about this is the patience to even attempt to explain free theorems to a 6 year old. Most parents would likely answer "math" and that would be the end of it. I don't (yet) have kids, but when I do I hope I have the wherewithal to recognize and take advantage of moments like these.

As a parent, I agree. One should not shy away from talking about "advanced" topics. Kids are naturally curious and bright and I think we should encourage their desire to learn and understand complex things.

I worry that if you try to dumb down things for kids, they might become interested in dumb things. :)

Also, as the OP mentions, it can be a fun "pedagogical challenge" to try to explain free theorems or turing completeness or MySQL sharding to a young child. And you may find a clever way to describe it, that they can easily understand, which is satisfying for both of you.

Re: Conversations with a six-year-old on functional programming

#16
post #3

What is truly astounding about this is the patience to even attempt to explain free theorems to a 6 year old. Most parents would likely answer "math" and that would be the end of it. I don't (yet) have kids, but when I do I hope I have the wherewithal to recognize and take advantage of moments like these.

Related, "Math from Three to Seven" by Alexander Zvonkin[1] is an excellent book on discussing math with young kids.

[1] https://bookstore.ams.org/mcl-5/

Re: Conversations with a six-year-old on functional programming

#17
post #14

When my son was around five or six, I did a similar exercise to explain the difference between prime and composite numbers. I told him that a number X is composite if you can fit X apples into buckets and end up with the same number of apples in each bucket. I drew 6 apples and asked whether they could be divided into buckets with an equal number of apples in each. It was immediately obvious that they could. My son c…

lol, is this some elaborate troll?

Re: Conversations with a six-year-old on functional programming

#18
post #4

Earlier quoted context omitted.

I'm curious what you mean. Is the problem that it is a constant function, or that you are asking them to ignore parameters? Or is that missing the point, still?

The child was stuck on the intuition that the argument must change in some way (i.e. that the function was linearly typed).

This and this:

>> I think he was just stuck on the idea of the function doing something arithmetical to the input, and was having trouble coming up with some sort of arithmetic procedure which would result in 6 no matter what you put in

don't really seem, to me, like they can explain what's happening -- f(x) = 6 is trivially easy to express in terms of arithmetic operations being applied to x. If you assume that a function that multiplies by 2 is intuitively ok, what's wrong with a function that multiplies by 0?

Re: Conversations with a six-year-old on functional programming

#19
Side question: maintenece of functional programs is easier, because you don't need to think about state.

Could it be used to create a functional programming language, easily understood by non-programmers or beginners , so they too could take a program and adapt it to their needs ? Does such language exist ?

Post reply on HN