This morning Cate and I were eating crepes with hazelnut chocolate and she asked me what this means? “10001001” I think she must have seen it somewhere on a piece of paper or an advertisement. I’ve always found it difficult to talk to her about what my job as a software engineer is, so I decided to use this a chance to get her more interested in computer science.
This is beginning of my attempt to start a series on educating kids on computer programming.
Computers are pretty simple machines, they do what humans tell them to do, no more. On the basic level, the computer has a brain, the CPU that is made of millions of transistors which has only 2 states, either on or off.
The 1 means it’s on, 0 means it’s off
Humans count using decimals 0123456789, computers count with binary. 0/1
Let’s start counting like a computer, turn on our binary brain. The numbers are all in binary.
0
is the number zero
1
is the number one
10
is the number two
11
is the number two plus the number one which is three
100
is the number four
101
is the number five
110
is the number six
111
is the number seven
1000
is the number eight
10000
is the number sixteen
100000
is the number thirty two
1000000
is the number sixty four
10000000
is the number 128
100000000
is the number 256
Then I started just asking her some random numbers like what
101, 110,10001
and she seem to enjoy it, great.
We started walking to the ZipCar to drive to Berkeley for school and I was explaining to her about pixels on the computer monitor. The typical monitor is 800 pixels across and 640 and each pixel is represented by a byte for each color. A byte has 8 bits. We have 3 colors RBG. Red, Green and Blue.
To make a color dot on the screen the computer has to turn on bits. So for the red part of the pixel, if all the bits are turned on R = 1111111, the pixel would be red. If R and B are both all turned on, the dot would be purple. R=11111111, B=1111111.
Cate then asked what is a computer language. I said a computer language is a very limited set of vocabulary that allows humans to talk to the computer and tell the computer what to do. Most computer languages have only about 40 words, much simpler than the French and Chinese that Cate is learning.
Cate: “Can I tell the compute to blow dry my hair?”
Tony: “Sure, let’s try it”
While Cate was in the back of the car seat, I told her, if we were to do it in JavaScript, this would be how we will tell the computer
var purpleHairdryer = new HairDryer();
purpleHairdryer.blowDry(“Cate”);
purpleHairdryer.stop(15);
var, new
are the only vocabulary words we used.
Before I left her at school, she asked me to give her at least 5 vocabularies from JavaScript.
I gave her var, new, for, do {} while, alert
Then I said goodbye and we’ll do more programming on Sunday. That was a fun morning. I drove back to San Francisco to catch my Yahoo! bus.
Note to self, there are plenty of links out there about teaching kids to program
Scratch from MIT looks interesting
More links:
http://www.daddymodern.com/what-is-the-first-programming-language-you-would-teach-your-child/
http://en.wikipedia.org/wiki/Logo_%28programming_language%29
—-
This is a series that documents my daughter’s curiosity to learn about computer programming
—-
Update 12/14/2010 : This post has also been published on the Yahoo! Contributor Network
Leave a Reply