Contents What Is a Bug 4 How Do You Write Code 6 What’s Your Language 8 Try Compiling 10 Using Interpreters 12 Debugging Scripts 14 Syntax Bugs 16 Runtime Errors 18 Logical Bugs 20 Mistakes Are Normal 22 Program with a Friend 24 Documenting Your Code 26 Can You Pass the Test 28 Glossary 30 For More Information 31 Index 32 Answers 32
What Is a Bug When the code you write has a problem we say that it has a bug It is actually pretty rare to write a piece of code and for it to work exactly how you want it to the first time Bugs are just a part of life for a coder It isn’t always the coder’s fault Sometimes the language you are using to write the code has a bug in it Debugging is what coders call it when they search through and find any problems in their code Sometimes a problem can be really obvious the minute you start to look Other times the bug can be quite difficult to find 1000100101001000 1101011000101101 0010100011101101 0100101101101100 1110100010110110 0010100101001000 1101011000101101 1000100101001000 0011000110000110 1011101011011010 Why are they called bugs One story claims that we use the word bug to describe these coding problems because a moth was found in an early computer at Harvard University However the word was used in electronics before that It may be short for bugbear or bugaboo which are old words to describe imaginary things that cause fear or concern such as goblins or spirits 4
What do coders do if they find a bug They change the code to fix it Then they test the code to see if their fix worked Debugging a piece of code can take time Sometimes a coder may need to repeat a set of steps over and over changing little elements each time until they get the result they want GET Programming How good are you at spotting mistakes Computers need really clear instructions to know how to do something They cannot think for themselves Can you see the mistake in these instructions telling you how to put your shoes and socks on What should the correct order be 1 Find shoes 2 Find socks 3 Put on shoes 4 Put on socks Answers are on page 32 5