Ask HN: How would you teach teens to code in 2019?
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 ] threadAlso, 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.
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.
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".
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.
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.
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.
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.
> 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.
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.
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.
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.
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"
This by far beats the maze games I would program in basic back in the 80s.
Today, I would start by playing a bit with the browser developer tools, and then move straight to shadertoy to produce cool opengl demos.
so start by finding a project. even better if they find the project on their own...
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.
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)...)
Teaching programming fundamentals via game projects. Things mostly from scratch, no engines.
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 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. :)
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.
Thanks for the comment and helping my memories! This has been a great thread.
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.
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.
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.)
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 :)
It's also a really great learning community, thanks to their "remix" feature (like forking on GitHub).
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.
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 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?")
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.