HICCUP
Contents
Hiccup - Introducing Computer Programming to Little Kids
- by Steve Baker.
Introduction for the Teacher
This work is designed to teach very young children something that most adults never learn. How a computer works and how to program it. We do this without the need to use a real computer.
This is achieved by having a group of children act out the various parts of an imaginary computer called SPARK (Small Programs And Real Kids). SPARK is made from odds and ends that you might find in a classroom like matchboxes, 3x5 file cards and a half dozen children. A calculator might be a useful accessory - but purists may want to omit it if the class has some children with sufficiently good arithmetic skills.
The activity will require simple reading skills, some basic math and a lot of enthusiasm.
The SPARK computer can run real computer programs written in a special programming language called 'HICCUP' which is quite like several real computer languages. SPARK computers run HICCUP programs - VERY SLOWLY. I present a couple of suitable programs in this book - but you can write more of your own. If your kids get into writing HICCUP then you can use a real computer to run them at a decent speed (THAT IMPLIES FORMALIZING HICCUP ENOUGH TO ENABLE ME TO WRITE A SIMPLE PARSER/INTERPRETER). Sizeable HICCUP programs can do real work and be useful (but not when run on SPARK because the kids get bored and make lots of mistakes).
The basic SPARK computer is very simple - but you can easily extend it with more kids - and add peripherals like a printer, colour graphics - and even a Robot.
Why Teach Programming? (An Aside)
Computers are amazing machines - whilst they may not have made as much difference to people as some other machines (The car, the plow, the flint knife), they are undoubtedly the most astounding.
What is surprising is that although a computer is really a fairly simple device, hardly anyone (outside of computer professionals) has the faintest idea of how a computer actually works. People are taught some incredibly low level stuff (Binary arithmetic) and some incredibly high level stuff (How to Surf the Web, How to Word-Process) - but hardly anyone understands the all important part in between.
Computer programming is a very important thing to teach children. It is hard to teach a kid the equations of motion - not because those equations are particularly hard - but because they appear to have absolutely no relevance to real life. When did YOU last need to use those equations in your day-to-day life? Have you EVER needed those equations in day-to-day life?
Think about this though - if you are trying to write a video game (something kids DO identify with) - and you want your character to jump over an obstacle in a realistic manner - you need to know the equations of motion! The idea of building virtual worlds in the computer is appealing - but forces kids to confront the mathematics of the real world. The computer can't do anything unless you tell it how - there is no way to bypass it. You HAVE to use math.
Well, HICCUP isn't going to do all of that - but it's a good start. It will certainly get everyone's enthusiasm going - and could lead into a formal programming course using a computer programming language like LOGO or BASIC.
Work to do before Starting SPARK
First, you need to get the kids thinking about what a computer is.
Here are some questions to ask - and what I think the answers are:
Are computers smart? | Well, there are computers that
can fly a plane or drive a car - there are computers that can play chess better than any human being alive today. On the other hand, they sometimes make incredibly stupid mistakes like sending you a bill for no dollars and no cents and demanding that you pay it immediately OR ELSE! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Do computers make mistakes? | They do - but very rarely. Computers are by far the most
reliable machines that have ever been built. An average car would be unlikely to go for more than 100,000 miles without something on it breaking. At 50mph, that is 120,000 minutes. If the engine runs at 5,000rpm, it does about 600 million operations before it breaks. A computer has to do 600 million operations every SECOND without making a single mistake for years at a time. You often hear stories about computers making mistakes - but the mistake is almost always in the programs that people write for the computer to tell it what to do. </td> </tr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Are computers good at numbers?</td> | Well, how about this -
computers don't know all the numbers 0 through 9. They only really understand 0 and 1. This makes counting a bit difficult - try it. ONE, TWO - Oh, no, it can't do TWO can it? - only zeros and ones, what's the next number it could do then? 3,4,5,6,7,8,9 - no. The next number it can do is TEN! OK, let's try again. ONE, TEN!, ELEVEN, ...uh... ONE-HUNDRED!, ONE-HUNDRED-ONE, ONE-HUNDRED-TEN, ONE-HUNDRED-ELEVEN, ...oh-oh...ONE-THOUSAND!?! Try counting some objects in 'binary numbers'. It would be hard to work with computers if they counted like that all the time - so one of the first things we write programs for is to teach them to use ALL the numbers when they talk to us. Once we do that, we can talk to the computer using all the numbers - and it'll change them into zeros and ones so it can understand us. It will even change the zeros and ones back into ordinary numbers so that we can understand what the computer is telling us. </td> </tr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Can computers do anything else apart from just numbers?</td> | No - not really. If the computer wants to use letters or make pictures
or sounds, it has to use numbers for all those things. It could do letters by making '1' be 'A', '2' be 'B, '3' be 'C' and so on up to '26' for 'Z'. Real computers use '65' for 'A', '66' for 'B' and so on - that's to leave enough spare numbers for all the other funny squiggles that computers need like '#' and '@'. This is called 'ASCII' (American Standard Code for Information Interchange). <p> You can try writing your name using numbers. (Interesting side-topic about secret codes here too. Write a message, turn it into numbers, add something to all the numbers and then turn it back into letters again.) Pictures can also be turned into numbers. Colour your picture on squared paper, then turn each square (A picture element or 'pixel') into a number using '1' for Red, '2' for Green, etc. You can turn the numbers back into a picture again by using a box of crayons with the right numbers written on each crayon. Draw a simple picture on a 10x10 grid, code it into a long list of 100 numbers and see if anyone can decode it. What happens if you miss out one of the numbers near the beginning? </td> </tr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
What can a computer DO?</td> | Not Much: All it can do is follow a set of rules called a 'program'.
Computers don't do ANYTHING without a program. </td> </tr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
How fast is a computer?</td> | When we run HICCUP programs on
SPARK, most children never manage more than one instruction every ten seconds - a 2GHz PC such as you might have in your home or classroom is about 20,000,000,000 times faster than SPARK. That sounds pretty fast - but there are still things that humans can do faster than a computer. Recognising the face of someone you know would be a good example. Computers have been designed that can do that, but they take several seconds to do it - something that the human brain can do in a tiny fraction of a second. </td> </tr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
How many computers does your family own?</td> | None? One? Maybe two? Well, I bet there is at least one computer
in your family car, another in the microwave, another in your TV and probably another one in the remote control, at least one in your DVD player, maybe one in your Air Conditioning controller, every pocket calculator or digital watch has a computer inside. Video games and cellphones are computers too. Even the big box you call "a computer" probably has three or four smaller computers inside it. Most families own a dozen or more computers without even knowing it. Think how hard it would be to go through a whole day without using a computer of some kind. </td> </tr> </table> Building SPARKSPARK is made from a number of separate parts - each one manned by either one or two kids. In order for HICCUP programs to 'run' correctly, the kids mustn't make even one mistake! Fortunately, the HICCUP language makes it quite hard for a mistake to happen - but it might be better to have two kids running each part so they can check up on each other. The PartsEach part is manned by a child who has to follow simple instructions given to them by one of the other children. It might be nice if each child wore a paper hat with the name of their part written on it. Between 'runs' of a HICCUP program, it's a good idea to change the jobs of each of the children so they all get a turn at each of the jobs. The UserThis isn't strictly a part of SPARK - but someone has to actually use the SPARK computer to type in data and to respond to output from the screen. It might seem logical for the teacher to be the user - but that's probably not a good idea - we need someone 'in the know' to try to catch mistakes that the kids may make as the program is running. The MemorySPARK's memory consists of a number of small boxes (matchboxes would be ideal), each clearly labelled with a letter of the alphabet starting at 'A'. Most SPARK programs will need only four or five matchboxes, but some programs might need more. The 'memory' probably ought to have around 16 matchboxes just to get across the general idea. Adding more matchboxes is a 'Memory Upgrade' - real PC's with 16 Megabytes of memory have (in effect) 16 million matchboxes. SPARK is a VERY low tech computer. The child who is 'MEMORY' should have a pencil and a pile of small paper squares (large enough to write a number on - but small enough to put into a matchbox - PostIt notes will do quite well). Each box can only contain one number. If MEMORY is asked to put a number into a box that already has one, then throw the older number away first. The Math ProcessorThe SPARK's math processor (called an 'Arithmetic/Logic unit' or ALU in a real computer) is just a person who does simple arithmetic when told to do so by one of the other parts of SPARK. It might be worth having a calculator at hand in case the arithmetic gets difficult. Some HICCUP programs need you to do division - and if so, then any fractional part (or 'remainder')of the result should be ignored. This is actually the case in real computers much of the time. 7 / 3 = 2 ! When computers need the fractional part of the result, they have to use techniques similar to the ones people use when doing long-division. The child who is 'MATH' also needs a supply of paper squares just like we gave to 'MEMORY'. The ScreenThis should either be a cardboard box with a screen-shaped hole in the front that the child can wear on his/her head - or a simple cutout panel that you can prop up with some books. The person who sits here either reads out (or writes on flash-cards) the output from SPARK so that the USER can 'read' what's on the screen. SCREEN is told to read out (or write down and flash) everything that anyone shows to him or her. The KeyboardThe person who is the keyboard should have a number of 'keys' that the USER can push. They should also have a pencil and some more paper squares. Most HICCUP programs only need a few keys to make them work. A key marked 'YES' and another marked 'NO' is important for most HICCUP programs. The program below needs '<', '>' and '=' keys. )It's quite amusing to use post-it notes with the key characters on them and to stick them onto the keyboard persons forehead, nose, fingers, etc. The USER's typing gets fairly amusing.) Whenever the USER pushes a key, the KEYBOARD person should write the key down on a paper slip and give it to INSTRUCTOR. The Instruction DecoderThis is the most important job of all. Each instruction in the HICCUP program is written out on a 3x5 file card with a hole punched in one corner. To avoid getting the all-important instructions getting lost or muddled up, they are best stored on a key-ring. The INSTRUCTOR is told to read each card in turn - and to do whatever it says. In a real computer, these instructions are held in the memory - (one file card per matchbox) - but that gets a little confusing so HICCUP programs are stored on a keyring. Real computers also convert each kind of instruction into a different 'code' number - so that programs are themselves just long lists of numbers. Some older programmers remember when you had to type the numbers into the computer - that's why they sometimes talk about 'code' and 'coding' instead of 'program' and 'programming'. A Sample HICCUP ProgramEach instruction is written on a 3x5 file card. Don't get them muddled up! This is a computer program to play the 'HiLo' game. The rules of 'HiLo' are that one person thinks of a number (bigger than 0 and smaller than 30 in this game), and the other person has to guess that number by asking just five questions. Most children find it very hard to guess the number with so few questions, so they will be quite suprised to find they can do it right every time when they participate in SPARK. The program can guess numbers from 1 to anything you like - in as few questions as mathematically possible - just change the maximum number written on the very first file card. Beware though that every time you double the maximum number, you add around three to five minutes to the amount of time the children will take to find the answer. When playing with people, you can let someone guess a number between 1 and a million and try to guess it with just 20 questions. So, start at the first card...GO!
So, what should happen is that the USER thinks of a number - and by asking a number of questions (at most 5 if nobody makes a mistake), the 'computer' should be able to correctly guess the number. This is interesting. The answer comes out right - but the 'computer' (ie the kids) have no idea how they did it! That's how come a computer can play world class chess - and yet still be a chunk of brainless silicon and copper. All the 'skill' was in the computer program - which in the case of our HICCUP program is just a bunch of inanimate 3x5 file cards. It takes about 15 HICCUP instruction cards to figure out which question to ask and it could take as many as five questions to solve the problem. It needs a total of around 80 cards to be read to get the problem solved (40 minutes at 30 seconds per card - I DON'T KNOW HOW FAST KIDS WILL BE ABLE TO WORK THESE CARDS - MAYBE FASTER THAN 30 SECONDS WITH PRACTICE). The PC in your classroom could do that in well under a millionth of a second. How long is a millionth of a second? Well, if you stood at one end of the school holding a flashlight, and turned the flashlight on at the same instant the computer started to run the program, the light from the flashlight would not have reached the other end of the school by the time the computer had finished working on the problem. I estimate that it could take a half hour to run this HICCUP program on a typical SPARK computer. If you want to cut it shorter than that then CHEAT! Pick an initial number that the program will guess more quickly. Alternatively, you could cut some time by reducing the initial value in box 'B' to 16 - although that's a lot less effective as a demo and probably only saves about 5 minutes. Here is a table of numbers and the number of guesses the program should need to get to that number (assuming 'B' is 30 as above):
Written in a more conventional programming language (like 'C'), the HiLo game program looks like this: #include <stdio.h> void main () { int A ; int B = 30 ; int C = 1 ; printf ( "Think of a number bigger than 0 and smaller than %d\n", B ) ; while ( 1 ) { A = ( B + C ) / 2 ; printf ( "Is your number bigger, smaller or the same as %d\n", A ) ; printf ( "Please type > for Bigger, < for Smaller or = for same." ) ; switch ( getch () ) { case '>' : C = A ; break ; case '<' : B = A ; break ; case '=' : printf ( "The number you were thinking of was %d\n", A ) ; exit ( 0 ) ; } } } Making ChangeWhat is the smallest number of coins it takes to make change for some amount of money? Write down the number of cents you want to make change for - and put that in MEMORY box 'A' before you start the program running. This program doesn't use the keyboard. Although the program is twice as long as HiLo, it runs fairly quickly for small amounts of change.
Here is that one again in 'C': #include <stdio.h> int main () { int A = 122 ; int C ; printf ( "The smallest number of coins for %d cents is:\n", A ) ; C = 0 ; while ( A >= 25 ) { A -= 25 ; C ++ ; } print ( "%d Quarters and ", C ) ; C = 0 ; while ( A >= 10 ) { A -= 10 ; C ++ ; } print ( "%d Dimes and ", C ) ; C = 0 ; while ( A >= 5 ) { A -= 25 ; C ++ ; } print ( "%d Nickels and ", C ) ; C = 0 ; while ( A >= 1 ) { A -= 1 ; C ++ ; } print ( "%d Pennies.", C ) ; } Robots - and onward towards LOGOYou can add another child to the team - the ROBOT. This robot has a SPARK computer in it's head that tell it what to do. Add new instructions on file cards to say things like "Tell ROBOT to turn left by 90 degrees", "Tell ROBOT to take 5 steps forward"...and so on. This 'Robot' is now controllable just like the 'Turtle' in LOGO. Kids who have written HICCUP programs to drive the robot will be well placed to slip into LOGO programming. Once the children have the idea of how the HICCUP setup works, they can probably work in pairs, one playing the robot and the other one running the program. When children write LOGO programs, they have to learn how to 'Play Turtle' in order to imagine what their program will do when they are in the process of writing it - and also in order to see what goes wrong when their programs have bugs in them. A DEEP ConclusionThe in 1997, the computer 'DEEP BLUE' beat Kasparov - who was the best chess player in the whole world at the time. (Arguably, he remains the best chess player who ever lived). If we rewrote DEEP BLUE's program in HICCUP (which would be quite easy to do) then SPARK could beat Kasparov. But hold on. SPARK is just a handful of school children following some simple rules. The kids might not even know the rules of chess. Could six kids who don't play chess really beat Kasparov? The answer is a conditional YES! Our kids could play world class chess and beat the best chess player in the world if they had enough time and a lot of matchboxes. The number of matchboxes needed would cover several acres of land - and it's doubtful that the kids would manage to read enough HICCUP instructions to work out their first move before they graduated from college - but that's not really the point - in theory, they could do it. So, we must conclude that the thing that beat Kasparov wasn't the super-powerful IBM computer, it was the SOFTWARE that ran on the computer.
a second, and probably took 10 seconds working out what move it should play. If SPARK could run one instruction per second, it would take those kids 10,000 years (working 8 hours a day) to make that first move. If they made one single mistake in all that time then Deep-SPARK's first move might turn out to be "Eat At Joes" instead of "b2-b4". How did the skills to play chess so well get into the computer? It was in the PROGRAM. How did the skills get into the Program then? Well, some person wrote the program that DEEP BLUE uses. We could explain what happened if that person had all the skills needed to beat Kasparov and just passed them on to the computer. Well, that can't be so - if he was that good at chess, he would be able to beat Kasparov and we know he can't do that or HE would be the world champion. |