I came across a strange statement at quora, where someone wrote

If available, learn to use its debugger. Although it is a good thing to learn how to debug without the integrated debugger, through the well-placed output messages.

Since then, I doubt the importance of a debugger. Should one really use it and depend on it for debugging a code, or is it just taught to us because we are enrolled in CS50x : Introduction to Computer Science, and they introduced this to make us familiar with it (just because we are at primary level), and afterwards(in our programming career) we are expected to do debugging by ourselves without the help of a debugger?


Learning how to debug your code is as important as learning to code. As your programs get larger and more complex, they'll usually contain many logical errors. Unfortunately, compilers can't detect logical errors (but rather, syntax errors) and that's where the role of the debugger comes.

An example of a syntax error

int x = 10 // missing semicolon

An example of a logical error

// infinite loop
for (int i = 0; i < 10; i--)
    // code goes here

It's almost impossible to be able to find exactly where exactly a logical error is in your code without debugging it. Debuggers help you execute your code line by line and see information about your code as it's already running (e.g., printing the value of a variable inside of a loop) which certainly helps you figure out where exactly problems are in your code.

Although you can debug your programs using a low-technique like throwing printf() statements all over the place, it's such a headache to come back and remove each of these statements from your code.

So this is not just CS50-specific. In fact, you probably won't be able to progress in this field unless you learn how to debug programs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .