10 ms·
Teaching Haskell to a 10 year old: Day 1
- actsasbuffoon 12y agoI struggled to learn Haskell in my early thirties. I think your son has a bright future.
- iamthepieman 12y agoMost of my problems with Haskell are related to getting rid of patterns and habits from other languages that are deeply ingrained. Assuming you have the mental models and internal language (which from the OP seems like a ten year old just barely has) it seems like it would be easier to learn Haskell at a younger age or at least before you learn any other languages.
- cronin101 12y agoI tutored Haskell to first-year students and I think the hardest part of picking it up is understanding that previous expertise won't help until you grok the distinctly new perspective with which you must approach problems. I'm (somewhat) sceptical of the popular "Children inherently have the most malleable minds" trope, to the grand annoyance of one neuroscientist friend; I feel it's more an environmental factor stemming from fewer areas of growth/stress to focus on and increased motivation as they lack the jack-of-all-trades experience in similar areas to fall back on whenever they get frustrated. I like to believe this since it motivates me to overcome those limiting factors by adapting my work ethic, with the hope to continue learning efficiently. Back on topic, I feel that the best mindset with which to approach Haskell (and many other new areas) is: "I don't get much right now, but that's OK. If I keep working with what I know and expand that set by just a little every day, it's bound to click and I will be able to look back on the entire journey as worthwhile."
- innguest 12y agoWell, you're not alone. I also think the "malleability" we see in children is just because of the attributes of their existence: nothing to worry about, nothing to do but play (and voluntary learning is play) and so on. And like you, I also use this to motivate me in Haskell. Little by little I learn things I didn't know before. It takes me years but I do it at the pace I choose. And why would Haskell be different from any other subject I learned as an adult? Everything makes no sense in the beginning, then it's hard, then you can kind of see what they're talking about, then you get some practice, and before you know it you are equipped enough to dig into intermediate stuff and then the advanced parts. Was it not the Japanese that came up with Kaizen - continuous improvement? I believe in that principle.
- godfreythadon 12y agoI, too, live by Kaizen.
- zzalpha 12y agoI feel that the best mindset with which to approach Haskell (and many other new areas) is: "I don't get much right now, but that's OK. If I keep working with what I know and expand that set by just a little every day, it's bound to click and I will be able to look back on the entire journey as worthwhile." And I think that, itself, is a mindset that children more easily accept. Children necessarily live in a world they can't yet fully understand (not that adults can, either, but we're more likely to live with the delusion that we can :). So I think they're more accepting of "you'll understand that later" than an adult is. So I agree with you, I don't think children are necessarily more malleable. But I do think they have a lack of ego, an openness to knew things, an acceptance (or maybe it's ignorance) of their own limitations, and far less fear of failure than the typical adult. And that I find incredibly inspirational, and something I try (and usually fail) to apply to my own life.
- deleted 12y ago[deleted]
- msie 12y agoI agree. The other day I was looking at some tutorial on Haskell type classes that I didn't understand earlier and it just clicked for me on the third-fourth try. We think, with our experience, that the learning-pipe going to our brain is the size of an oil pipeline but it's really only the size of a straw.
- dcre 12y ago> No, son, your mom just phrased the question badly. Aaaaaand... I am an asshole. Thank you for reminding me.
- therealdrag0 12y agoIs it because you assumed it was a dad? Me too. :(
- AnimalMuppet 12y agoWell, I assumed that it was a mom, but that's because we homeschool and my wife does most of the teaching. Which is no less sexist... :(
- justathrow2k 12y agoDon't be too hard on yourself. By your own admission you assumed the sex of the author just because you have a wife who is teaching your own child. As far as my understanding of sexism goes this is miles away from being an example of sexism.
- krick 12y agoI was under strong impression it was post by woman before I even opened it: just saw the blog name.
- lgas 12y agoI'm sorry but none of this is sexist. Making an assumption about someones gender, race, age, etc based on what is most common (or most common to you) does not make you a sexist, racist or agist. It just makes you human. If, after realizing your assumption was wrong, you said "omg, I can't believe a woman knows haskell, how did she ever learn that?" THEN you're being sexist.
- borgia 12y ago>Is it because you assumed it was a dad? Me too. :( Yeah, god we're such shitlords, aren't we? Time to go give myself some lashings at my home built shrine to Ellen Pao. Seriously though, this is entering the realm of stupidity. You made an assumption based on your own experiences (that the vast majority of computer programmers and enthusiasts are male) and one that is backed up by data - the vast majority of computer programmers and enthusiasts are male. Coupled with that assumption is the many other various "I'm teaching my kid to program" blogs and similar that pop up here from time to time that to date, as far as I recall, have all been written by men. A story about a programmer is highly likely to be male. A story about a programmer regarding their son wanting to learn programming and them teaching them is likely to be a male teaching a male. When women are showing the same level of interest in computers, in programming, in computer science, etc. as their male counterparts and are blogging, developing, taking part in the community at the same level, then it may be questionable to automatically assume it must be a man teaching his kid to program. You are as sexist in your assumptions here as you are in your transphobia in automatically assuming the son is "cisgendered". C'mon now, let's take a large step back from this nonsense.
- AnimalMuppet 12y agoSounds like the big issue she's going to keep running into is that a 10-year-old doesn't really do abstractions well (and doesn't have the background to do abstract algebra yet), whereas Haskell expects a certain familiarity with abstraction. It could be, though, that showing things in concrete, and then introducing the abstractions, is the right approach to teaching Haskell for nearly everyone, not just 10-year-olds...
- zzalpha 12y agowhereas Haskell expects a certain familiarity with abstraction. I'm curious why you think Haskell is unique in this regard. I mean, sure, if you want to understand why things like Monads exist, I agree, that fundamentally means grokking some pretty deep abstractions. But I don't know that you need to understand those abstractions to use and appreciate Haskell... maybe to fully use and fully appreciate it, but I wouldn't expect that of a 10 year old to begin with, in part because I wouldn't necessarily expect that of an adult either.
- AnimalMuppet 12y agoYes, I had things like monads in mind, but also currying, and higher-order functions, and I could probably think up a couple more if I tried. True, all languages require abstractions. But it seems to me that Haskell is more abstract than most. That's it's strength, in fact. But it seems to me that it also creates something of a mismatch when trying to teach it to a 10-year-old.
- zzalpha 12y agoHuh... weird, I don't really think of currying as much of an abstraction. I mean, if you're going to be rigorous about it, maybe, but you can cheat and explain it as partial function application, which gets you 99% of the way there, and I think is pretty easy to explain. Higher order functions are certainly a bit trickier, but you could explain them in specific contexts (as with 'map') without needing to deal immediately in generalizations, which probably makes it a lot easier to explain.
- smenko 12y ago>> ...and just turned 10, has been nagging me for ages to teach him Haskell... I'm guessing you would have taught your human(?) kid some human languages first before he started nagging you (why you, he can read too, right?) to teach him Haskell. I think you had a dream or sumping...
- bbcbasic 12y agoI think he will have a harder time not having not studied algebra (yet?). Maybe it would help to explain why in regular maths + and * have similar properties. For example they both return the same result regardless of order of parameters. They are both conform to ((a <op> b) <op> c) = (a <op> (b <op> c)) Where <op> can be + or *. Now we are getting a bit abstract but keeping it kind of concrete, without using scary terms like 'associativity'. And once he is used to abstractions he may find Haskell easier. I was lucky to study Maths at Uni, so to me Haskell makes a lot of sense. Although the foldr/foldl/applictive/monad stuff is a mind bender I have to admit, but well worth persisting.
- pbhjpbhj 12y ago>let double x = x * 2 vs. >hasn’t had any algebra yet He has now. ;0)> Simple variable assignment is algebraic mind you so the assertion doesn't match with the note of having studied some programming already. Functions are algebraic too. I'm guessing the parent here is thinking "he's not studied a formal course specifically targeting a subject area referred to as algebra".
- pbhjpbhj 12y agoI don't know Haskell at all, the ~"all functions only have one argument" concept interests me. >"had an easy time explaining how (2 * 3) really is two functions, each with one argument and one result, and he drew it out on paper nicely" // So, like you pass the multiply function an argument which is a list (2, 3). Or is it more like you pass the multiply function the first operand (2 in this case) and it returns a function multiply-by-2 which you pass the second operand? The latter seems like it would get sub-optimal pretty quickly. Mind you surely here the compiler produces the same sort of assembly [repeated addition here] making it just a way to abstract around an alternate mental model. I've just looked at https://wiki.haskell.org/Currying https://wiki.haskell.org/Currying, could someone walk through how something like arcsin(0) works - that's probably a bad example - something that takes a single variable input but has multiple solutions (returns n.π in this case, but say sqrt or an anagram function or ...)? I'm sure you can tell I'm not a computer scientist, not even a programmer ...
- Saavedro 12y ago> Or is it more like you pass the multiply function the first operand (2 in this case) and it returns a function multiply-by-2 which you pass the second operand This is exactly it. You can literally write: multiply_by_2 = (*) 2
- deleted 12y ago[deleted]
- spion 12y agoIt returns the multiply-by-2 function. This turns out to be super useful map (* 2) [1, 2, 3] will take that function and apply it to each element in the list [1,2,3].
- pbhjpbhj 12y agoThat map function looks a lot like it has 2 arguments, a function and an operand array (ie a list)??
- 12y ago
- octatoan 12y agoYour son is lucky. That's all I'll say. :)
- akurilin 12y agoHaving found out in person how superginbaby teaches her kids, I realized just how primitive my upbringing was many years ago :)
- nnq 12y agoWhat Haskell is mission in order to be more learnable by anyone imho is sane error messages. The simplest example I can think of is typing foldl + 100 [1, 2, 5] in the repl by mystake instead of foldl (+) 100 [1, 2, 5] and getting an error message that starts like Could not deduce (Num ([t0] -> (b -> a -> b) -> b -> [a] ->.... ...instead, it should fking yell at you that you gave some wrongly typed arguments to the function (+), and you'd instantly realize what's wrong: "...but I'm not trying to call + ...oops, forgot the parentheses around it. fixed!". Also, auto-currying in ML-family languages probably doesn't help with making meaningful error messages easy to implement because it gives more variants for what the user could have meant (besides making type signatures 10x harder to read and making implementing named arguments or optional arguments with default values close to impossible... if they could have just used a postfix $ after the function name as currying-trigger, but no, they've had to use this for some more error-prone and hard to read "syntax sugar" because making people just type a few more parentheses would've been too Lisp-y for the haskellers taste...).
- octatoan 12y agoI don't think this is as easy as you make it seem. A whole bunch of problems in typing and deduction are undecidable in the general case. (Don't know about this one, but just saying.) Also, you seem a little aggressive toward "Haskellers". I'm sure you didn't mean to be! :)
- nnq 12y agoThe thing with "undecidable in the general case" is that 80% if the time you can just heuristically guess an be right. Most bugs are shallow. Typos, forgetting operators etc. And even if the guess is just plain wrong, I think that a wrong simple guess is most of the time better at nudging the learner in the direction of fixing the mistake than an incomprehensible type deduction explanation... And if it's not you can always have it under some kind of "details". And no, I don't think this is "a job for the IDE"... this would be Java-think :) ...and that't the thing, when guessing what's actually wrong, syntax can help a lot. Things like having the equivalent of an auto-curry-on-off toggle at the syntactic level, would make guessing at least 50% easier. And other little things too. I think ML-lamnguages tend to shoot themselves in the foot here. C-like syntax has a clear advantage when it comes to enabling guessing and heuristics. I didn't mean to be agressive, I love the concepts behind Haskell... this is why I hate the "little things" that ruin it and make it almost unusable for average "don't make me think too much right now" type developers (like me after some sleep deprivation or a couple of beers or during a "this bug needs to be fixed by yesterday morning" sprint :) ).
- c22 12y agoI never really knew what people were talking about when they mentioned currying until I read this article.
- deleted 12y ago[deleted]
- Viktoras25 12y agoSon: “Well. Hm. If the function is the (+), then you first apply that to the 1. So…..you have something like (1 +)? And now you apply that to the 2? And then you get the final answer?” Seriously? He grabbed the idea just like this? Am I that old and stupid, that partial application didn't seem to me that easy? Or is currying what kids learn in a kindergarten these days? Sorry for my ranting, I'm just really amazed. A humanity went a long way to understanding such quite abstract conceptions as number 0 (as absence of something). And at 10 years kids, i think, are still learning by seeing, touching, playing. So concluding a much more abstract idea seems really fantastic.
- deleted 12y ago[deleted]
- renox 12y agoI'm curious, why Haskell? Children tend to like visual feedback (I know I did) so Logo, Scratch would probably be more rewarding for him.
- wz1000 12y agoCodeWorld(http://codeworld.info/ http://codeworld.info/) sounds like a good fit for the author.
- NoodleIncident 12y agoBecause the kid asked about Haskell. This is explained in the first sentence of the article.
- deleted 12y ago[deleted]
- wz1000 12y agoCodeWorld[0] provides a nice graphical environment in which to learn Haskell. [0]: http://codeworld.info/ http://codeworld.info/