Re:Ask HN: What are the best tips to teach programming to kids?
by nikisweeting on Monday March 06, 2017 @06:56PM
(#13807204)
I find the hardest things for new programmers to understand are variable scope, and execution order.
One of the things I focus on when teaching is evaluating different example code snippets manually, as a "human computer" to double check that their mental model of the interpreter/compiler is correct. Understanding why a variable is shared with a child scope, but not necessarily with a parent in different circumstances is not intuitive, and takes some practice even for intermediate-level programmers.
Here's an example:
Code snippet:
int result = addNumbers(1, 3)
int final_result = addNumbers(result, addNumbers(4, 5))
To evaluate it, these are the steps the computer takes:
1. int result = addNumbers(1, 3)
2. int result = 4
3. int final_result = addNumbers(result, addNumbers(4, 5))
4. int final_result = addNumbers(4, addNumbers(4, 5))
5. int final_result = addNumbers(4, 9)
6. int final_result = 13
Re:Ask HN: What are the best tips to teach programming to kids?
by laurieg on Tuesday March 07, 2017 @12:48AM
(#13808530)
Teach concepts before code.
For example, if I'm teaching kids what variables are I bring out a bunch of boxes with labels on them. The boxes represent the computer memory. I can put numbers in the boxes. I can put other things in boxes, strings and so on.
I find a lot of people get confused by the difference between a variable name and its value. This isn't helped by the the fact that almost all programming languages use equals for assignment.
Only after showing them the concept thoroughly do I introduce code. I treat code as "telling the computer what I want to do" and the activity as "what I want to do".
One of the things I focus on when teaching is evaluating different example code snippets manually, as a "human computer" to double check that their mental model of the interpreter/compiler is correct. Understanding why a variable is shared with a child scope, but not necessarily with a parent in different circumstances is not intuitive, and takes some practice even for intermediate-level programmers.
Here's an example:
Code snippet:
To evaluate it, these are the steps the computer takes:For example, if I'm teaching kids what variables are I bring out a bunch of boxes with labels on them. The boxes represent the computer memory. I can put numbers in the boxes. I can put other things in boxes, strings and so on.
I find a lot of people get confused by the difference between a variable name and its value. This isn't helped by the the fact that almost all programming languages use equals for assignment.
Only after showing them the concept thoroughly do I introduce code. I treat code as "telling the computer what I want to do" and the activity as "what I want to do".