Ask HN: How would you teach teens to code in 2019?

82 points by evolve2k ↗ HN
My son and daughter are growing up and after setting them up with Linux machines and kids coding activities (Scratch, Coding Minecraft w Java, Shoes.rb and more) a few years back I think it’s time to teach them to code proper.

I have experience in ruby and react and currently work as a Digital Media Designer.

What resources would you suggest? A. As a curriculum To run a small code club with them and a friend or two with homework in between

B. Self directed online resources they can use to level up themselves?

I’ve always loved ruby but am aware that JS is king and also want them to have exposure to functional languages also.

87 comments

[ 4.4 ms ] story [ 143 ms ] thread
Teens/Childs quickly loose interest in something. Find out what they find "hip" or cool, don't expect it to be what you find cool. I would rather support them to program their own Instagram app then to propose them to some hardware programming environment (thinking of educational boards) if they don't like it.

Also, learning programming was applied autodidactics for most of us, isn't it? My feeling is that this is the only really working way of learning programming (have worked 10y in university, teaching programming: Doesn't work well).

It really depends on your kids and on your relationship to them. Maybe you should present them a vast amount of programmable devices and interfaces to explore together interesting projects.

It's the content on IG that's fun, not the app itself. Take it from me, someone who half-learned JS and PHP through extremely tedious "build your own FB" tutorials that took 2 hours of setup work (VirtualBox, MAMP, MySQL DB setup, etc etc) before you even started "coding".

At best they will end up with something not much more than a static website that can accept image uploads. Forget about live video, stories and the stuff people actually use on IG.

I think a simple game would be better. Easier to see results early on, at which point you can dive deeper into the mechanics of what's happening.

You nail it: I find "Instagram" as an application interesting, because it can be approached really easy (file upload and viewer). That even you don't find it interesting anymore supports my point that it should be the kids who decide what to code. I never had an interest in developing games. When I learned JS and PHP (~15yrs ago), I created tons of dynamical websites which nobody used, but which were fun to code.
If they have interest in it, by all means. Programming is a very slow learning curve, which can be frustrating for most people. I would personally start with very highly specialised / abstracted programming environments. If they like video games, using things like construct or, harder, Unity might be a good inbetween. Because of scenes editor and such, you can create something nice just with a series of drag and drop, and just write a few simple scripts to make it a bit more alive. It's also good to start on existing tutorial and try to customise them.

If they aren't interested in video games, it might be harder to sell programming as a hobby. I guess there is something a bit more magical to "hey, I managed to make this cube move when you press the joystick, and then when you press A it jumps" vs "hey, I have a sign-in form for my app".

Well it is difficult because there are so many distracting things and programming environments are not very engaging for kids. My two daughters had great fun assembling Lego Mindstorms and Robotis Bioloid kids (with the smallish metal screws). We then downloaded the examples programs to which I did a few changes in front of them, and tried to explain stuff. But clearly they showed no interest in the programming activity. So I did not insist. I may try some time later with an Arduino: I think it is by far the less sucking programming environment for young people, and it basically works (and is text based).
Do they show an interest? Same as playing an instrument you can get them one, teach them a few tricks, send them to classes and then, well, they either want to pursue it or not.
I agree to the extent that a hands-on person might not care for or see the value to learn programming. I had arguments with my younger brother about learning software programming, whereas he liked building computers and building out networks (I’d jibe, ‘pulling cable’).

That said, I don’t think music education is a good analogy, unless you’re working at Guitar Center. I’d say it’s more like learning Spanish, if you want to be a food service manager. It’s not your job to speak nor write in Spanish for Spanish speakers, but it’s damn useful.

So what I’m saying is you don’t have to become a programmer to realize the value of doing a data analysis task in a fraction of the time it takes in Excel. Especially how business likes to pile on work (now you have one more thing to do every week) in a way that design and project-based work does not.

Agreed that they should show an interest before you embark on this. Finding joy in general education is more important than job skills for that age.

That said, Ruby and JS are not great languages for teaching fundamentals. They (especially JS) have a lot of weird design decisions that don't translate to other languages and don't map neatly onto problem spaces.

If you insist on JS, start with TypeScript at least. But maybe D, Kotlin, Go, or Dart would be better to teach general concepts.

Python would be a good add-on because they could actually use it to write quick utility scripts and, eventually, data analysis.

Instead of linear programming exercises, it may be easier to find problems they find interesting and help them Google their way through solving them. Maybe they have some tedious homework they could learn to automate.

The problem you'll find is that kids don't do much work, so programming (i.e. making a computer do work for you) isn't necessarily that exciting yet.

When first learning it's more enjoyable to see an idea translate quickly to reality.

JS is great for that purpose. It's very easy to make animations and other fun effects in the DOM or build an extension on top of their favorite site. Once invested they might start research and discover CS fundamentals. Immediately throwing them at typescript without understanding JS could lead to frustration/confusion.

They also might learn an appreciation for things like type safety by not having them. For that reason dynamic languages like Ruby /Python are great. They can execute an idea faster, and if they get frustrated by those types of issues then introducing them to those other languages. Kotlin is cool, but it makes a lot more sense if you have had to deal with null pointer errors before.

I finally learned Javascript after hating two compsci classes that used Java. I really like Javascript or Python for beginners, I think other languages are too strict and are not "fun" to learn for beginners
Java's strictness used to be tedious and redundant. Don't assume all strict languages work like Java. Type inference in Kotlin, for example, is fantastic.

Strictness with good error messages is much better for beginners. That's why I use the strictest possible language in professional work: if the compiler can do a bunch of work for you, why not let it?

Strictness is like bumper lanes or training wheels.

It's easier to use Kotlin to make fun animations than JavaScript, because Kotlin has better autocomplete. The DOM is neither the only (nor the easiest) presentation layer when you want quick results.

> Immediately throwing them at typescript without understanding JS could lead to frustration/confusion.

I don't understand why you think this would be the case. They could write plain JavaScript in a .ts file and get better error messages. There's no downside.

It's also frustrating to constantly have to check docs for JS libs instead of using autocomplete. A good static type system makes coding much faster and require less memorization of things like parameter order or return types in libraries.

>Agreed that they should show an interest before you embark on this. Finding joy in general education is more important than job skills for that age.

Thank you for including this in your comment. So many people are trying to force programming down kids' throats when the child may not even have an interest in it.

Programming is the future! Everyone needs to know how to code! Nearly everyone can write some piece of code for use in their every day life to make it easier! I disagree. Code is good for kids who have an interest in it, because after so many months of not doing it, the kids that didn't refresh the knowledge will be nearly at square one.

>They (especially JS) have a lot of weird design decisions that don't translate to other languages and don't map neatly onto problem spaces.

As someone who started with JS, I feel like this is a valid point, but also ... not really a big hurdle to overcome later down the line.

It's one of those things that is really apparent when comparing languages, but I'm not sure matters as far as learning goes. No doubt someone has run into someone who can't do anything outside JS, but I'm not sure that is all that common.

I feel like if you're at all capable, it's almost no hurdle, and the benefits of being easy to start, can do some front and back end work, are pretty big.

Very much agree on kids showing interest. I didn’t even have much choice, when my kids weren’t interested, they wouldn’t do it. Now that they’re interested, they’re self-motivated, exploring and begging me to help them.

As far as language choice goes, I’ve tried to teach my son Python and a couple other languages, but he’s not that interested. He’s choosing JS and is self-motivated to learn because he can share his creations with his friends super easily, and because he can edit JS files directly on his website that doesn’t need to run a back-end. That’s not really built-in to any other language. TypeScript is closest, of course, but for a kid the prerequisite of learning npm and a transpiler and installing them on a server are huge hurdles.

Personally, having worked in Python, C++, and JavaScript professionally for a couple decades, I’m not in the least bit worried about my son learning JavaScript and being able to use what he learns in other contexts, not even a little. All languages have oddities, and IMO JS doesn’t have more than any other language, they’re just different. JS is really great for asynchronous thinking and quick to prototype interactive web pages and games.

Seconding the idea of finding them problems that they can solve or things they can build that they find interesting.

Programming to make their homework easier? Great.

Programming a game they can show their friends, that lets them compete to get a high score? Great.

Programming some interesting scripts into minecraft? Great.

Programming to learn to how to reorder a red black tree? ="programming is boring"

I don't think waiting for obvious interest is a good idea. I believe in putting as much as possible in front of children as soon as you think they are ready. If they show interest in something, then foster that interest, but don't force them if they don't. I never had an interest in coding before it was put in front of me, and I know many others in the same boat.
I have been teaching my 5 year old daughter Scratch. But we make animated stories and add funny sounds. She has a blast doing it. I am gradually teaching her more complexity but keeping it fun and interesting. I will try to make a course out of it at some point.

This by far beats the maze games I would program in basic back in the 80s.

Personally, I would think twice and instead help them find what they are good at (or have interest in). Future will include content creation of sorts.
Like the rest, if they are interested. I think, again like others, that something with better fundamentals than JS would be good as then JS won't be hard to take up. I learnt coding in the early 80s by programming games. But when it came to making money I used those skills to build business applications. And I liked that as well (I like the feeling of creating something that works 'out of nothing').
Something fun to start in might be GreasyMonkey kind of stuff were they can manipulate existing sites. That could introduce them into a lot of programming areas while still allowing small changes to have big results.
This. My 12 year old son was never very interested in school coding (Scratch mainly), but when shown how to manipulate existing web pages using Inspect in Chrome that really caught is imagination.
yes, definitely. My father teaching me to code as a kid was a very happy time!

Today, I would start by playing a bit with the browser developer tools, and then move straight to shadertoy to produce cool opengl demos.

code for code's sake is usually boring. using code to do something you already want to do can be fun.

so start by finding a project. even better if they find the project on their own...

So true. I think that finding a project involves listening to the child/young adult and listening is a bit of a skill!

I think trust is also important. So if you can do a collaborative project where you do your bits and they do their bits then it should all work out.

Then you need some imagination. To think of a project. It should satisfy a personal itch. Or a neighbour's problem.

A good breakdown of roles is for adult person to do some hardware, even if the computer interface is just a switch and a relay and then the computer bits can be done by the young person.

I would say that listening is important, particularly if you want the young person to be owning the project.

You should differentiate between the different aspects programming involves. I sure do see logical thinking as the most important aspect of development. Also Algebra is important, but well above the understanding of a younger child. If you look for example into Game Design you get a lot bigger area of interest that is combinable with programming, such as UI, Art, 3d, Sound, Story, Mechanics and Level-Design, etc.

Getting them directly into programming directly will likely be the wrong attempt, because (in my opinion) programming requires a lot of frustration tolerance and if done the wrong way will spoil it for them. Also combining an existing interest with development, such as using their painted characters in a game might create interest in content creation.

In our Game Design BA, we also give a summer school course for kids (12-18 years), that teaches them to develop a game in GameMaker during 2 weeks. Other visual development systems such as GameMaker might be good as well. Afaik lego also has a visual programming system for it's mindstorms system.

If you you insist on classical programming languages i'd suggest python with some ui based libraries (for example pygame, not because of gaming, but because of graphics, sound and interaction aspects) or processing.

I also consider gaming as an important aspect of learning. But the game has to change often, othervise it's just enjoyment to get perfect in a system that you already mostly understand. I usually reach this point after 2 to 8h in a game, because i want to understand the logic of the game. If you enjoy the story, you have to go trough the whole game usually. To reflect on the things you played and experienced is good to learn as well, but usually spoils the fun. There are a lot of games that teach logic thinking and often contain logical structures systems or train logic thinking. (minesweeper, sudoku, kerbal space programm, bridge builder games, lots of construction games (minecraft)...)

If I had to teach a class right now, I'd teach them on Raspberry Pi's and with some command line / terminal capability that includes SSH. I would probably bring in mathematics, taking care to separate the two pedagogically. I think the rest of the details would depend on the age of the kids in the class.
Exactly. Command line /terminal should be the first step in any learning that takes place on a computer.
I did a video series with this in mind: gameswithgo.org

Teaching programming fundamentals via game projects. Things mostly from scratch, no engines.

I learned to code on GW Basic in the 1990s. My first programs were simple games like: try to guess which random number the computer picked, you'd input a guess, and the computer would respond with higher, lower, or correct (IF-THEN-ELSE). You'd get to keep guessing until you win (LOOP).

Those might be mundane coding examples for teenagers, but it taught me the basics of logic.

Functions is one thing I wish I had learned about a lot earlier than I did. Also how to commenting out lines of code, rather than deleting them. And how to use the debugger. These are no-brainier concepts now, but I was 10-years-old and self learning from books with some guidance from my dad and brother.

I would definitely say stay in the web development area of programming. It's really expanding at an incredible rate. HTML, JavaScript (All the frameworks), CSS, PHP, etc.
When I was quite young, I started 'programming' by copying code out of magazines. I would run home from school, open up a magazine, write code until dinner, run downstairs after and write code until I had to go to bed. If I repeated that often enough, I would eventually (if I was lucky) be able to compile my code, fix the 14,000 missing pieces of punctuation and then have a (very primitive) game to play and share with my friends.

I don't recall learning much, but I was at an age where I was more concerned with getting Nario to jump over a bucket than with actually learning. I likely did learn something, maybe even just a passion for sitting in front of a computer and making it do cool things. I'm sure I also learned that if you really want something, just put in the hours and jfgid. For me though, the operative part was games. I wanted to play games and at some level, I wanted to learn how other people built amazing games for my Tandy.

The point of all that (other than 7:30am nostalgia) is that, for me at least, I had to be motivated. I had to want the end result enough to push through the grueling bullshit of it all. To this day, I believe that the only way to learn to code is to fall in love with a project to such an extent that you can't stop yourself. Whether that's a good lesson for teenagers will have to wait...my kid is only three, so I have a decade of self doubt to interfere. :)

I fear that this kind of passion is now harder to achieve, because kids are shown that computers can do amazing stuff from very young age but anything that you can produce yourself will be woefully behind. Back in the day a game copied from a magazine was worse than what one could buy, but not _that_ much worse.

This is why, I think, we see people "coding" in Minecraft and Roblox. They have all of the environment set up for them and can do cool stuff which they can immediately appreciate.

That’s an excellent point that time had kind of glossed over for me. When you mentioned that, I remembered playing a couple of commercial games. You’re right - they were better, but not that much better.

Thanks for the comment and helping my memories! This has been a great thread.

While I agree to a certain extent with the point you made in your first paragraph, I'm not sure why you doubt quoted coding with regard to Minecraft and Roblox. Both games have Turing complete languages. Roblox uses Lua.

Minecraft uses javascript on Bedrock, but also has a command block scripting language along with redstone, which together form a unique and mentally stimulating coding environment.

This isn't even mentioning mods which add different languages (Forth or Lua) or modding the game itself, which isn't that difficult to stumble into these days.

Oh, I did not know that (I was only familiar with redstone).
This is more "resource" than "curriculum" but have you seen Glitch.com? It's a combination hosting service/dev environment/playground that has lots of example projects that can be forked and modified, many of which are things that they might find interesting (messing around with Spotify playlists, etc.).
I would direct them to a game style coding session as gaming can be a stepping stone for some.

For me gaming led to wanting to mod the games, which led me learning how mods were created and learning to 'break' the game.

I am not affiliated with them however I did stumble across a DApp programming 'game'

https://cryptozombies.io/

If they like the above at that point I would direct them to other programming languages.

First one is Beaker Browser. I know this isn’t a popular technology - but that’s not important to a teenager. I have been teaching some teenagers how to build little JavaScript apps in Beaker (no npm or git yet) and it has completely caught on for most of them. These are kids familiar with Scratch but not text-based languages.

The nice thing about Beaker is:

* They can write dynamic apps without needing to write server code. (We are working on note-taking apps and home pages that save to the file system.)

* They can share their stuff and link to each other without needing to publish anywhere. This also makes it a kind of private network, so it feels like a safe place to make mistakes.

* Has a built-in text editor and file manager. Eventually they will learn more - but let’s start with just the HTML, CSS and JS - that’s already a lot to take on.

* Concept of versioning is built-in, so hopefully this will make it easier to teach source control.

Other good tools that I have enjoyed using to teach elementary-age kids: Twine is amazing. And Scratch (as well as Scratch Jr on touch devices) are good preparation.

To determine interest level, I like to have them watch over my shoulder while I build something small for five or ten minutes. (Don’t go too long.) I start by just showing how HTML tags work. This will excite many of them - they may even start to conjure up ideas right away - if it doesn’t excite them, then perhaps the interest isn’t there. (Or they might not understand something like HTML yet and need something simpler.)

If your kids get into coding and if they're doing Javascript (which I think is a good place to start for lots of reasons, but python might be better) I can personally recommend Free Code Camp for learning basics and intermediate topics in javascript web development. The interface is thoroughly gamified and it's very effective for people who are, but ONLY after they're enthusiastically hacking away at web dev. They'll be much more successful at learning the basics once they realize that they want and need the basics.
when I was learning programming as a kid it was all about video games. Quake was a new game and it had an embedded language called QuakeC that controlled the game logic. That was hugely fun for making Quake mods. That set me up to do programming in Perl and C.

I would probably play to their interests with projects that are more concrete than abstract. If they are into video games, lots of games have mod languages and they can start by giving themselves more health, more power, different weapons etc. If they are into social media maybe javascriptlets to edit the DOM on a website to change peoples tweets and take a screenshot, twitter or insta bot that automatically responds to certain types of posts, etc.

Teenagers should be able to grasp non-toy languages and the concept of searching StackOverflow for how to do stuff :)

Glitch is amazing. It solves the development environment problem better than anything else I've ever seen - you can spin up a new environment entirely from your web browser without installing anything, and seconds later you have a dynamic website that other people can visit.

It's also a really great learning community, thanks to their "remix" feature (like forking on GitHub).

I also really appreciate that you can get started playing around without making an account.
I'm super grateful that my first exposure to programming (high school in Eastern Europe, 10+ years ago) was in C++. I don't think we even did a lot of C++ specific stuff so it was probably closer to C but using cout instead of printf. Covered things from if-statements and loops to sorting and tree-searching algorithms. It doesn't sound flashy and it somehow goes against the trend to try to make learning exciting, but it lays a really nice foundation in your learning.
This.

I learned programming from doing C, and man am I glad I did. I thinm if my first language had been something like JS it would have been a major impediment.

Yeah, the nice thing about C is that it really doesn't take much to start writing and running C. A text editor and a compiler is all you need, and unlike say Java there's not a ton of boilerplate you need to handwave when writing "hello world".
I would not focus just on programming but on projects. I would get a few Raspberry PIs and some electronic components and let them build and program devices. Build a simple weather lab for temp, humidity, etc. Build a silly traffic light that is triggered by a motion sensor. Have a lamp that can be controlled from a web page.

Programming isn't just about web apps and mobile games, so teach them how to build simple projects. Their eyes will open up to all the things computers control all around them. That way they get to decide what they like, hardware, software, both, neither.

I started with BASIC programs written on my TI-86 to automate math problems; they may find that a useful way to get started, and learning a little BASIC shouldn't be much more brain-damaging than learning Javascript.

I kind of have a problem with training people to "code" rather than teaching computer science; feels sorta like comparing a "wine and painting night" to a course in oil painting, in that you might shortcut to something acceptable-looking but with little understanding of how or why you did it. But they're kids and will probably quickly tune out during Dad Explains Linked Lists :)

Ideally I'd suggest starting off with some smaller guided exercises to get them familiar with the language, then work with them to spec out and implement a more interesting project. In my CS courses in college we implemented the minimax algorithm for tic-tac-toe and checkers, starting with a tic-tac-toe engine which just printed out its desired move and evolving along until we were displaying a checkerboard as it played along. Could be a good project for you since it's implementing something they're familiar with (board games), doesn't use anything weird like networking, and can introduce concepts such as recursion and complexity ("if we have it calculate the next move, how many possible moves are there? What if we calculate the next two moves? The next three?")

I remember geometry in 9th grade. I ended up programming my TI for all the formulas so it would prompt for the variables then you hit enter and viola, perfect answer every time.

We had a test where I ended up finishing in about 10 minutes. The second person to finish took 30 minutes +. In hindsight I should have went slower because it was obvious no one could have finished as fast as I had.

After the class was dismissed the teacher obviously asked me to stay after class and asked me if I had downloaded all the formulas I had used.

I explained that I did not download/transfer from someone and that I had programmed the calculator to do it for me.

Teacher called me out (probably not believing it) and asked me to program the volume of a cylinder.

Took about 10 minutes to write it up quick, showed it worked and rather than reprimand me the teacher did something amazing.

She said something along the lines of, "If you understand the formula enough to write a program to do it for you, that shows you understand it at a higher level. Rather than punish you, I will still give you a 100% and you are allowed to use your calculator for the remainder of the class as long as you do not share your program(s) with anyone else."

I never had many friends (loner nerd type) so that was easy and it was the easiest 100% I had ever gotten.

Hah, it was geometry class for me too. Lots of plug-and-chug arithmetic, no logic required, translated perfectly into simple calculator programs.
I had a calculus teacher in 11th grade who followed the same principle. Best math teacher I've ever had. Didn't give us 100%, but the calculator programs were worth extra credit.