Ask HN: Is teaching my 8yr old son a functional language first a bad idea?

31 points by sergiotapia ↗ HN
I want to teach my son how to program and I've been wondering what language to start with. I work with Ruby day-to-day but if I teach him that first I feel like it'll sully him for other languages and "taint" him.

I was thinking of going with Go since it's very basic, clean and explicit. It's a C-style language so he will be able to branch out to other languages years down the line if he wants to.

On the other hand, distributed systems are on the rise and probably the future of computing. Something like Elixir will go a really long way in teaching how how to think in a functional, distributed manner.

What do you guys think? Fathers, what languages have you taught your son first?

39 comments

[ 2.0 ms ] story [ 92.6 ms ] thread
My oldest is a girl who spends several hours a day drawing comics so I'm not sure she would enjoy programming, bu tI do have some thoughts on the subject as a person that has taught children programming.

I find that functional languages force the user to think in a more artistic, creative way than imperative languages. It's out of the box thinking by design. The danger is that if the student is interested enough to push past the initial discomfort of being lost, you risk poisoning the well for some time (maybe forever).

Learning programming is stumbling through the woods no matter the language design, but functional languages can be more brutal.

If the person in question hasn't been exposed to anything else there's no unlearning. It's easier to teach a non-programmer FP than a programmer that's been exposed to imperative programming only (at least in my experience).

Not including Haskell here.

Functional programming certainly changes the way you think about many problems but I'm doubtful learning an imperative language first is detrimental.
It depends; I should amend it to say that if all that is focused on is imperative programming it can be a greater leap to FP than if the initial learning is either a comparative class or FP-first.
Imperative programming is just functional programming where some (many) of the inputs and outputs are hidden :)
No reason not to start with FP. Arguably even better.

I wouldn't use a brace-language first, though. I'd stick with Logo, Smalltalk, Python, or Scheme, preferably in a decent environment, e.g., Logo or Scratch.

The issue with starting with brace-oriented languages is that they spoil you in different ways. Ceremonial languages are a harder sell, less fun, and AFAIK don't have good kid-oriented "IDE"s.

(Processing might be an exception since it has reasonably-friendly IDEs and provides immediate feedback.)

Worrying about "spoiling" this early because of Ruby seems odd to me. It's a low-ceremonial way to get started, it has enough power to do anything necessary including teaching "higher-order" programming. But without Shoes it lacks the immediate feedback loop for kid-like programming (shapes, graphics, games, etc.)

Above all else, it should be fun. If your son finds programming enjoyable, everything will fall into place.

For that reason, I'd suggest a language that enables you to easily make things. I actually think Ruby is perfect, because you can teach him to make websites using Ruby on Rails.

I personally have a soft spot for rails because it's how I first got interested in programming. I had no experience in coding and don't have a CS degree, but hacking on rails projects is what initially sparked the fire for me. Two years later I'm working my dream job at Google - that never would have happened if there wasn't a fun, interesting gateway into the programming world.

Would love to ask you a few questions about how you got from point a to b, mind if I drop you an email? I don't see an address in your profile
I suspect you are taking it a bit too seriously, it just needs to be simple and fun, don't make it a chore.
Full disclosure, I'm not a father, though I have thought a lot about introductory CS education.

1. Let the student drive the learning.

We all have our own views of what fields are interesting, exciting, and worth studying. They've been shaped by our own past experiences and views of what's important or useful at large.

Students, especially young students, are still forming their worldviews. It's possible to condition them to think one way, but these views will always feel "forced" or "alien" compared to views they arrive at themselves.[^1]

Thus, it's important that the students drives the learning. This is largely done by perpetually asking questions. Knowing the answer without being intimately aware of the question is nearly useless. Curious students will ask better questions, internalize the knowledge better, and drive their own learning.

As it turns out, this applies to all learning, not your specific question related to programming/computing. Let's explore that question next:

2. Prioritize computational thinking.

Specific choice of languages in industry come and go. You identify this trend yourself: in recent years languages like Go and Elixer appear to be gaining popularity, perhaps even at the expense of languages like Ruby or Java. Whatever the general trend maybe, language choices always vary. However, there are two tenets which remain relatively constant.

a. "Computational Thinking" provides a framework for problem solving

Computational Thinking, as popularized by Jeanette Wing[^2], basically just means thinking about solving problems in a way that formulating the solution resembles the process by which you could encode the solution on a computer. Regardless of the choice of language, programmers and computer scientists still approach problems algorithmically and formulaically. This skill set is more important than knowledge of any particular language.

b. Language paradigms change infrequently

Across all the industrial trends in language choice, languages in popular use can largely be categorized by the extent to which they utilize two paradigms: the imperative paradigm, where programs are built of a series of state mutations, and the functional paradigm, where programs are built from mathematical functions with a focus on composition.

Familiarity with both of these paradigms is important, and indeed they complement each other.[^3][^4] Most languages are not purely functional nor purely imperative. However, being able to recognize and identify these features will facilitate learning new languages as they arise.

3. Embrace child-like wonder.

As we get older, there's increasing pressure to not be "surprised." People say things like, "Wait, you didn't know that? Everyone knows that." As a result, we are conditioned to contain our excitement when learning new things.

As it turns out, people are learning and getting excited about things all the time. Excitement is infectious; if you are always excited and passionate about the things you're learning (or teaching!), that excitement will spread to those around you.

> Never lose sight of that child-like wonder. It's just too important. It's what drives us.

> -- Randy Pausch, The Last Lecture

—————

[^1]: Cf. Inception

[^2]: Computational Thinking, Jeanette Wing. https://www.cs.cmu.edu/~15110-s13/Wing06-ct.pdf

[^3]: When Carnegie Mellon restructured their entire introductory course sequence in 2010, it was driven by these ideas. Freshman take two courses: Principles of Imperative Computation, in C, and Principles of Functional Computation, in Standard ML.

[^4]: Introductory Computer Science Education, A Dean's Perspective, Randal Bryant et al.

I'm far from a father but you really seem to take this too seriously. Introduce him, yes, if he has fun he will want to continue by himself and probably nag you. But don't try to distract him with whatever your ego seems fit for an extension of "yourself" and "your son". He might as well become a heart surgeon if you let him have his space to be and explore.
It's a mistake on your part to assume my parenting style based on 4 paragraphs.
I'm not assuming anything, really. See if you see yourself in what I wrote. If you don't, disregard.
I wouldn't worry too much about the language, try to link it to something they enjoy. If your son enjoys video games teach them javascript/html5 and let them build in-browser games they can easily show off to their friends. If your son likes to tinker with physical things, do an arduino project with him.
Does your son have an interest in programming? Does your son have an interest in something related to programming? How are your son's reading, writing and typing skills? Programming, by nature, is very deliberate. Misspellings and typos can cause a world of hurt for an experienced dev and could be even more frustrating for a kid. A lot of programming is less about the language than it is about the concepts.

In light of the above, I am going to make an out of the box suggestion...

Buy a Lego Mindstorms kit. Build a robot with him and then use the software to put together basic programs for the robots with the programming software that is included. You will be able to teach him simple if statements, loops, conditionals, variables, etc all without having to worry about what language to use and without him worrying about spacing and punctuation.

When I was a kid I loved doing this. I was always playing with Mindstorms, setting up courses, and seeing if my programming lets them work their way out of them. I also would set up different courses for the two types of wheels that came with my kit. I had to learn that bumper sensors had to be out further than the wheels. I had to be able to turn on and off motors for the right length of time to make the robots turn. I could use light sensors and I even tried to figure out how to make it annoy my sister. There was some building, sure, but a lot of my time was spend "programming" with the Mindstorms software.

Then I tried to jump to C++ or C# (cannot remember) when I was 9-11 and I was miserable. Granted, my parents had no programming experience and I tried to kind of do it on my own, but it was a bit much for me. I just didn't enjoy it and quickly left it alone.

If your son enjoys Mindstorms, maybe in 12-24 months you guys can start with real electronics and a formal programming language. The cool part is (especially if you have an interest) this (ie. hobby electronics and programming them) is something that could be something you do with your son that lasts a lifetime. That is always a positive!

Good luck and have fun!

Edit: Here is a pretty decent overview of the programming that is involved. There are more tutorials on the channel if you want to get more of a feel for the interface before you buy. https://www.youtube.com/watch?v=81hctQt6Cp8

He's actually asked me about my work many times. I think I'm going to go the lego mindstorm route. Any particular "package" you recommend?
That is awesome! :) Asking the questions I did wasn't a judgement on you, by the way. I was hoping that they could judge the best "in" for your son.

I honestly have no idea about the Mindstorms set. The one my parents bought me is probably 20 years old at this point. I also won a sweet R2D2 one at the mall at the tail end of when I was really playing with them.

Maybe see if there is a set out there that matches one of his favorite fictional characters? Does he tend to favor things with wheels or things that walk when he is playing with toys? (ie would he rather program Wall-E or Iron Man?) Maybe do some basic research and present him with three options? Or maybe start from the "problems" he wants to solve and work with him on building/picking the right robot out. Some questions could be:

- Do you want to walk around the kitchen?

- Would you like to build a track for your car to follow?

- Want to scare your little sibling with a giant scorpion while having plausible deniability? :P

Lego seems to have a huge gallery of bots that people built [here](https://www.lego.com/en-us/mindstorms/gallery). They all may be able to be built with the "default" kit, which I found on [Amazon](http://a.co/15WLhTC).

Just the basic, although I'm less positive about the latest iteration than previous. I'd also load up on some Technics kits for extra parts.

There are also some great Lego mechanisms books that can be folded into Mindstorms work so it's not just programming, but also mechanical engineering and design. The more integrated it is, IMO, the better, by far.

I agree with the others that you might be diving too far into the deep end here. I'm about to start teaching my 7 year old a little bit about coding and am starting with Wonder Workshop[1]. Its a suit of toys (robots) that are approachable and fun and give the kid instant feedback. Something more high level like that might help you teach your child the overarching concepts that will inform more complex ones in the future. Best of luck!

[1] https://www.makewonder.com/

Ooh! Those are neat! They look Lego Minstorm-ish. Cool!
Building levels and maps for video games can be a great introduction to the type of thinking that can later be used to learn programming and building more complex things.
Apologies for my many disorganized thoughts here. Consider also soliciting suggestions from mothers.

Do you think Elixir will help him solve a problem that is interesting to him?

Kids would probably be most immediately motivated by a language that allows them to execute interesting effects right away. Declarations, definitions, and tautological wiring are all probably the least interesting things.

I don't know if "spoiling" a budding programmer is really a thing. However, I suspect it may be easier to go up the ladder of abstraction than down. For example, after using a primitive line-oriented version of BASIC as a kid for a while, I wanted more structured constructs, and could understand how those structures worked in terms of conditional jumps etc.

I accidentally introduced my son to PICO-8 (which uses Lua). I was evaluating alternatives, he noticed the icon for it and asked about it, and that was that. He hasn't done much programming with it; he's more interested in drawing and making music. Then again, he's only six years old. I think the specialized screens for editing graphics and music make it easier for him to just not think about programming at all, in a way that wouldn't be true if he had to draw graphics with LINE(x1,y1,x2,y2) etc. In short, probably don't use PICO-8.

My start with primitive BASIC dialects is probably biasing me, but if there were a fake assembly language with a simplified interface for interacting with the environment (sound, graphics, text input), that sounds like it would be ideal. You don't even need to understand block structures to start with this sort of thing.

> In short, probably don't use PICO-8

Whyever not? It sounds like a great playground for a kid who might be interested in art, music, programming, or any combination of the above. (Or he won't bother with it for long.)

The kid's eight, for pity's sake. Give him a chance to find his interests.

IMHO you should try with something very simple like python or php.
It's the best thing you could do for your son.
Not a father, but very much interested in pedagogy of programming. I initially got interested in this because of the (now infamous) paper 'Camel has two humps'[1].

Since then, the author has redacted his conclusions, but I still think the paper points to a very interesting thing, some people are different, they just don't "get" programming the same way we do (and this is hardly an indication of being less intelligent, but that there are different kinds of minds out there).

My theory is that the main culprit here is Turing Machine architecture. That people who don't 'get' programming actually might like it better if they are taught lamda calculus based programming first.

I tried teaching my intelligent non-developer buddy programming using a non-FP language which he absolutely didn't get, but when I tried teaching him lamda calculus that made a lot of sense to him, so I am interested in seeing more validation of this hypothesis.

So my suggestion is that you try teaching your son any kind of programming, and if it doesn't work out then try teaching him the other kind. For FP, I recommend teaching him lamda calculus and this game [2] is a good place to start with.

1. http://www.eis.mdx.ac.uk/research/PhDArea/saeed/paper1.pdf

2. http://worrydream.com/AlligatorEggs/

Worry more about an engaging approach and interesting projects than the first language. If you are worried about the language being limiting, introduce another one or two after a while; a language or language family is limiting if it is all you learn for many years, but otherwise probably not.
Go with racket and look into some of teaching languages. I would avoid C-like languages because of the memory model.
I wouldn't worry about limiting language syntax just for him to be "able to branch out to other languages years down the line if he wants to."

As far as I remember, my first brush with programming might be when I was ~7, on an old, crt-connected computer (not comodore, something Yamaha branded, with arabic OS I found at my grandpa's), with the Basic programming language. As far as I remember, I was able to comprehend PRINT, INPUT, IF and GOTO, I don't think I was able to handle sub-routines and loops. Your mileage may wary :)

I really started \w programming 10y old, with after-school course in Visual Basic for Applications. It was the year 2000 and that was only ide our teacher was sure we would have at home :-)

I remember, that sub-routines were fine for me by that time, loops and array iteration as well, interestingly, I took some time I comprehended, that I can do i.e "x = x + 1". This wasn't something that my brain thought was possible, based on my experience in math class (we have been solving simple linear equations by that time). So, functional language might have been easier in this regard :-) Unfortunately, I don't remember when I managed to grok recursion?

We made a lot of text adventure games \w input and message boxes first, and later on drag-n-drop some forms together. Two years later we worked with C. Three years later in Java. In that time my accomplishments were at the level of single level top-down shooter and we might have accidentally invented the clicker genre :-)

So, if he wants to try ruby, wouldn't worry about somewhat tainting him. If you think it would be fun to learn elixir, and want to take your son along, and write a game together or something like that, that sounds like fun as well.

Hope my account helps, I would like to hear how did your effort go :-) I have a three year old daughter, and one day I will want to share programming with her as well :-)

an interesting functional programming language is OpenSCAD he may enjoy making onscreen objects and optionally 3D printing them, at the same time learning some of the basics of functional programming
(comment deleted)
I dunno the first language I ever managed to figure out was TinyScheme (running on Gimp), which is considered functional. I actually found more OO-style languages to be harder to understand. But that might just be me.
MindStorm and Scratch are great ideas. When you venture into something more real, give QuickBasic (QBasic) a shot. It was part of the Windows 95/98 Power Pack addon for free if you have one of the old cd's lying around and it's a great way to start.

I say that because that's how I started when I was 12; found some tutorials online; has very basic functions, is text-focussed and lets you get started, fast. After; I'd move to C# since that enables you to use the friendliest IDE out of all (Visual Studio) and it's a great language and relevant to the job market now and in the forseable future.