TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Conversations with a six-year-old on functional programming (2018)

580 点作者 _ttg大约 5 年前

24 条评论

dmlorenzetti大约 5 年前
<i>\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.</i><p>One Christmas when my whole family got together, I made a &quot;stink detector&quot; which consisted of a USB cable stuck inside a ziplock bag. My nephews were invited to put anybody&#x27;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&#x27;s owner) in a GUI.<p>Under the hood of the GUI was a grep engine that checked for a whitelist of names and titles (&quot;uncle&quot; 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.<p>They spent a long time varying the parameters, trying to figure out how they affected the &quot;analysis&quot; before figuring out it was all driven by the name.
评论 #22945968 未加载
Scapeghost大约 5 年前
The most key point of this is right at the start:<p>&quot;I decided to just answer straightforwardly&quot;<p>That can make all the difference in your interactions with your child and how they learn about this world.<p>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 &quot;you&#x27;ll understand when you&#x27;re older&quot;. If they&#x27;re not able to understand or decide they don&#x27;t want to, they&#x27;ll stop asking.<p>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&#x27;t defend it to them, why do you follow it?<p>Who knows, maybe you&#x27;ll even make an unexpected friend to share your interests with. :)
评论 #22945359 未加载
评论 #22946477 未加载
评论 #22948560 未加载
评论 #22945499 未加载
grey-area大约 5 年前
I find kids understand the concept of functions really intuitively if it is stated simply - input -&gt; func -&gt; output, it doesn&#x27;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.<p>Another game I play with my kids to introduce the concept of functions which aren&#x27;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.
评论 #22944122 未加载
评论 #22944524 未加载
评论 #22953582 未加载
评论 #22944762 未加载
maze-le大约 5 年前
&gt;&gt; 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...<p>To be fair, this is a bit beyond most who had no contact with functional programming and category theory.
评论 #22944385 未加载
jpz大约 5 年前
&quot;He gasped in astonishment at the idea of putting function machines into function machines&quot;<p>&quot;He gasped in astonishment as I carefully explained the results of the double-slit experiment.&quot;<p>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?<p>I hate to lose reputation with downvotes for sounding negative, but I find my credulity challenged with this story.
评论 #22945382 未加载
评论 #22945618 未加载
评论 #22945396 未加载
评论 #22944614 未加载
评论 #22945310 未加载
评论 #22945845 未加载
评论 #22944743 未加载
评论 #22945727 未加载
评论 #22945475 未加载
评论 #22945550 未加载
评论 #22945153 未加载
评论 #22945914 未加载
minipci1321大约 5 年前
I was 16 and learning FORTRAN at school. I was a lazy bum at that time (well, that stayed ;-), didn&#x27;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 &quot;a value is calculated when the rest of the code needs it&quot; (like in regular math that we did a lot at the time too). She said &quot;not correct, it executes in the order it is written&quot;.<p>-- I doubt she knew anything about functional programming back then.<p>-- It took me 40+ years to get to the universe where this answer was not completely laughable.<p>-- And meanwhile what 16 y.o. kids were doing at the time, 6 y.o ones are capable of doing now.
评论 #22955139 未加载
评论 #22944328 未加载
chime大约 5 年前
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 &#x27;x&#x27; and he returned f(x) to me. Eventually we ended up at Collatz Conjecture and he absolutely loved it. I&#x27;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&#x2F;max worked out perfectly. He completed the entire chain of 7 on his own! Thank you :)
porsager大约 5 年前
I remember the first time this was posted, almost 2 years ago. I&#x27;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&#x27;s such a good way to make things like these interesting. Thank you!<p>ps. Maybe add [2018] to the title?
sideshowb大约 5 年前
I will try to remember this in a few years time!<p>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&#x27;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.
评论 #22994551 未加载
serpix大约 5 年前
My seven year old would glaze over somewhere in the first sentence and switch topics to Pokemon.<p>Your child might be gifted.
评论 #22944863 未加载
评论 #22944020 未加载
评论 #22944191 未加载
soared大约 5 年前
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.
sytelus大约 5 年前
Surprising because I have seen few 6 years olds can do multiplications and divisions. If I&#x27;m not mistaken, standard US 1st grade curriculum expects kids to be familier with only addition below 100 and subtraction in low teens.
评论 #22944199 未加载
评论 #22957003 未加载
评论 #22944181 未加载
defaultcompany大约 5 年前
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 &quot;Oh so like food is input and poop is output!&quot; Yes we are all functions!
评论 #22946366 未加载
foobarian大约 5 年前
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 &quot;X made out of &lt;p1&gt; made out of &lt;p2&gt; made out of &lt;p3&gt;....&quot;. Was cool to see how tickled she was by the idea.
gigatexal大约 5 年前
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&#x2F;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.
jcpst大约 5 年前
My daughter was in kindergarten when I first read this a few years ago. She loves the “guess what the function does” game.
teekert大约 5 年前
So nice! This morning my 7 y&#x2F;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&#x27;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...
OJFord大约 5 年前
What&#x27;s the optimal strategy for choosing inputs in order to guess the nature of the machine?
评论 #22944282 未加载
评论 #22944386 未加载
评论 #22944497 未加载
rednosehacker大约 5 年前
Such a beautiful story about love and passion. Thank you for sharing this inspiring annecdote !
dang大约 5 年前
Discussed at the time: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17015661" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17015661</a>
d--b大约 5 年前
I remember having these kinds of games all the time in middle school in France. They also were called &quot;machines&quot; at the time.
shric大约 5 年前
(2018)
评论 #22944511 未加载
gregoriol大约 5 年前
Maybe we should let kids be kids and do kids stuff instead?
评论 #22944510 未加载
评论 #22944079 未加载
评论 #22944113 未加载
评论 #22944220 未加载
评论 #22944544 未加载
评论 #22945675 未加载
rb808大约 5 年前
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&#x27;t easy, which is why most code bases are not FP.
评论 #22955285 未加载