With humans writing Megas of lines of code every day, it's easy to make mistakes. Coding mistakes are also known as bugs.
Searching for these mistakes and finding a way to clean your code are important parts of programming. When humans are at it, they like to say "I'm debugging my code!".
Becoming a good detective is key to learn how to write programs that make what you want.
But, how can you improve your detective skills?
First, you need to know that there are different types of bugs, as in real life. You know about bees, moths, and spiders! They are all bugs, but different.
With programming is the same. Sometimes you might find a mistake that has to do with your writing. For example, you might have missed an "i" or a comma ",".
Other times, bugs can be more difficult to find, because at first, it seems that your program is running just fine. It's only when you look closer that you'll discover that your program isn't doing what you want.
The first 'computer bug' was reported in 1947 by Grace Hopper. But, it wasn't an ordinary ‘program bug’...
When her colleagues opened the computer to see what was causing the errors, they found a real-life moth!
Hopper then sellotaped the moth into her diary.
Spot the difference
(also known as 'debugging' time)
The program below writes "Hello, Human!" on your screen. You're seeing two versions of it but, one of them has some bugs!
Can you spot them? ✏️
Hooray-bits! You just became a detective with debugging experience. Remember that understanding computers is a SUPERPOWER, so keep on learning!
Lots of Megas from The Binary World, 👋
Zerus & Ona
PS. Keep learning with what repositories are, what a bottleneck is and how to raise your children's interest in technology.