How to debug a C/C++ program with GDB command-line debugger​​

The art of “debugging” — why we all need to learn debugging to create new stuff

As a child we learn at school the idea of “right” and “wrong”.

What is 2+3 = ?
If the answer is 4, we are told its wrong.
If the answer is 5, we are told its right.

We are taught “arithmetic” to understand the rules and know what is right and wrong. However, how did the child reach the answer “4” is the key to solving the puzzle in the child’s head. Not whether something is right or wrong. As we learn English, science, and even physical activities we get into this habit of understanding what is right and wrong.

In the real world, when we move into jobs and careers we take this instinctive understanding of the world of black and white and see our roles and activities we do in life as right or wrong. We got that “memo” wrong. We did the interview right. Both are not fully useful.

In innovation, we talk about failure and learning from failure. However, I see that the key challenge here is the mindset we learn from school of “right” and “wrong”. The mental model we carry is the key challenge to learning from failure.

In the book Mindstorms, Seymour Papert, discusses the mental model of debugging in computer programming as a key learning outcome. A bug is an error in the program that needs to be corrected through a process of “debugging”.

He writes:

“What we see as a good program with a small bug, the child sees as “wrong”, “bad”, “a mistake”. School teaches that errors are bad; the last thing one wants to do is to pore over them, dwell on them, or think about them. The child is glad to take advantage of a computer’s ability to erase it all without any trace for anyone to see. The debugging philosophy suggests an opposite attitude. Errors benefit us because they lead us to study what happened, to understand what went wrong, and, through understanding, to fix it. Experience with computer programming leads children more effectively than any other activity to “believe in” debugging.”

This is a quite powerful in my view.

In the work I do with startups and large organisations, we coach the idea of design thinking — to prototype, to test, to put it out in the world and see what works and what doesn’t. These are great ideas but hard to implement because of mental models and organisational structures.

Whether the smallest startup or the biggest organisation, it is about breaking that pattern of thinking. How can we enable people to learn this mindset? One method seems to comes from computer programming — the idea of debugging that Papert discusses above.

We need to think of the work we do in the same way and study what happened, to understand what went wrong and through understanding, fix it.

If we can teach people the idea of debugging then we can start to get better at experimentation, learning and eventually innovation.

May be we all should learn to code!

Like what you read? Give Suhit Anantula a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.