Amazing what kids can learn
Posted: Sun Dec 17, 2006 3:38 pm
So my 10 year old daughter asked me to teach her how to write programs 'like you do at work daddy'. So I brought her into the room, opened up and editor, had a brief discussion on servers and server-side language scripts, then explained what PHP is and how it works on the server, then had her write her first program.
This evolved into
At about this point my nine year old came and asked to participate along with us. So we got to throwing some stuff out and this is what we ended up with after about 20 minutes:
My daughters, in about 20 minutes, now understand how to declare and assign a variable, how to tell PHP what a string is and what an integer is, how to write a conditional (if/elseif/else), how to write a while loop, how to increment a counter, how to use a function (and what a function is) and how to read the PHP manual. Frickin amazing.
Me: How does PHP know when it is the end of the line?
They: The semicolon.
Me: What do the quotation marks on a variable value mean?
They: That the value is a string.
Me: If we loop do a while loop where a var is less than 100, what is the maximum value we'll see when echoing the increment value?
They: 99.
Me: And if we change the increment value to 10, what is the largest value we'll see?
They: 90.
Unbelievable. Even a 9 and 10 year old can get this pretty quickly.
/ apologizes for the blog like post, but I just wanted to encourage those folks that think this is too hard to pick up on. Start slow and it can be learned. Just ask my kids.
EDIT | I should note that they are by no means pros at this. But they have a strong understanding of the concepts, as evidenced by their ability to tell me what would appear on the screen as they read the code line by line.
Code: Select all
<?php
echo 'hello world this is sarah';
?>Code: Select all
<?php
$text = 'hello world this is sarah';
echo $text;
?>Code: Select all
<?php
$text = 'hello world this is sarah';
$num = 10;
$joiner = ' and I am ';
if ($num == 10)
{
echo $text . $joiner . $num;
}
elseif ($num == 11)
{
echo 'I am 11';
}
else
{
echo 'I am totally not 10';
}
echo '<br />';
$counter = 0;
$limit = 100;
$inc = 10;
while ($counter < $limit)
{
if (!($counter % 10))
{
echo '<h2>10 is a modulator of ' . $counter . '!</h2>';
}
else
{
echo '<p>I am only ' . $counter . '</p>';
}
$counter += $inc;
}
$now = time();
echo date('l F jS, Y', $now);
?>Me: How does PHP know when it is the end of the line?
They: The semicolon.
Me: What do the quotation marks on a variable value mean?
They: That the value is a string.
Me: If we loop do a while loop where a var is less than 100, what is the maximum value we'll see when echoing the increment value?
They: 99.
Me: And if we change the increment value to 10, what is the largest value we'll see?
They: 90.
Unbelievable. Even a 9 and 10 year old can get this pretty quickly.
/ apologizes for the blog like post, but I just wanted to encourage those folks that think this is too hard to pick up on. Start slow and it can be learned. Just ask my kids.
EDIT | I should note that they are by no means pros at this. But they have a strong understanding of the concepts, as evidenced by their ability to tell me what would appear on the screen as they read the code line by line.