Sequences, bugs and debugging: coding ideas in Robot Code
Robot Code looks like a simple puzzle: line up arrow blocks so a robot reaches its battery. But it uses the same ideas that real programmers use every day. Here they are.
Algorithms
An algorithm is a set of step-by-step instructions to solve a problem. A recipe is an algorithm. So are the directions to a friend's house. In Robot Code, your row of blocks is an algorithm for getting the robot to the battery.
Sequence: order matters
Computers follow instructions in exactly the order they're written, one at a time. "Forward, turn right" is completely different from "turn right, forward". Getting the order right is called sequencing, and it's the first big idea in coding.
Computers do exactly what you say
A computer never guesses what you meant. If you tell the robot to go forward into a wall, it will. This can be frustrating, but it's also what makes computers reliable: the same program always does the same thing. Programmers learn to think very precisely about what they're asking for.
Where "bug" comes from
A mistake in a program is called a bug. Engineers were using that word for faults long before computers existed, but there's a famous story about it. In 1947, people working on the Harvard Mark II computer found that a real moth had got stuck inside the machine and was causing an error. They taped the moth into their logbook with a note about the "first actual case of bug being found". The computer pioneer Grace Hopper, who worked on that team, loved telling the story, and the logbook page is now kept at the Smithsonian museum in the USA.
Debugging
Finding and fixing bugs is called debugging, and programmers spend a lot of their time doing it. Good debugging habits:
- Watch it run: in Robot Code, the white outline shows which block is running. Notice exactly where things go wrong.
- Change one thing at a time: if you change lots of blocks at once, you won't know which change fixed it.
- Explain it out loud: programmers call this "rubber duck debugging", because explaining your code step by step, even to a toy duck, often reveals the mistake.
- Check your assumptions: is "left" really the robot's left? Is it facing the way you think?
Efficiency
The game gives three stars for using the fewest blocks. Real programmers care about this too: shorter, simpler programs are easier to read, faster to run, and have fewer places for bugs to hide.
What comes next
Real programming languages add more ideas, like loops (repeat these steps) and conditions (only do this if something is true). Once sequencing feels easy, you're ready for them. Read teach kids coding with games or make your first game for the next step.