Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

After yet another homework question on SO. It seems like that vast majority of students have no idea what a debugger is or how to use one. I feel that knowing how to use a debugger is almost as important as other fundamental of programming.

  • The question is shouldn't debugging and how to use modern debugging tools be taught alongside programming fundamentals? If not why not.
share|improve this question
2  
Erm.. you're saying gdb is a modern debugging tool? It's not a bad debugger, but it's certainly not state of the art. –  Billy ONeal Jun 11 '11 at 1:45
1  
I would Agree but I have also answered question were students use visual studio and didn't know how or why they would use a debugger. –  rerun Jun 11 '11 at 1:53
    
@rerun: Erm.. ouch. They can't hit the "play" button on the IDE? (BTW, I +1'd) –  Billy ONeal Jun 11 '11 at 1:54
    
system.out print logging is the last bastion of the lazy and inept –  Jarrod Roberson Jun 11 '11 at 3:39
6  
@Jarrod, a pretty broad generalization and perhaps overly so. Sometimes you simply cannot use a debugger on your program where the problem occurs. –  user1249 Jun 11 '11 at 5:36

7 Answers 7

up vote 6 down vote accepted

It's not so much the case that the use of debuggers that needs to be taught, but the more general techniques of debugging. This would include teaching how to use a debugger of course but would also various other important techniques, e.g.

  • critical thinking
  • divide and conquer
  • printf debugging, logging, etc
  • desk checking
  • stress testing

As an additional benefit, many of the techniques can also be applied to problem-solving in areas other than programming.

There's quite a good book on this whole subject, which should probably be required reading for all undergraduates and anyone learning the basics of programming: Debugging by David J Agans.

share|improve this answer

Figure it out on your own

I didn't need and didn't want a professor or T.A. to take time teaching me something I could easily figure out on my own. They are there to teach me the hard concepts and guide learning. They aren't and should not be there so you don't have to RTFM.

Learn How To Learn

College should be about learning how to learn, not just having your hand held through every topic you don't know. If you have your hand held constantly through this process you will fail miserably in the real world.

Uphill, Both Ways, Through the Snow

When I went to school they didn't bother to teach you the language either. You were expected to pick it up on your own time. They would give you the project and facilities. It was up to you to track down the information you needed in order to complete the implementation and submit a working program. Pretty similar to the real world, except with office hours.

share|improve this answer

This question is foreign to me. At my university the use of the debugger (JDB and the Eclipse debugger) were taught as early as the first-year computer science sequence. The use of debuggers and other testing tools were taught again in the course on software testing.

I personally find it incredibly difficult to believe that any good school that is attempting to prepare people for entry into the workforce isn't teaching about proper debugging and testing techniques. They obviously can't cover all aspects of it, but they can at least teach the basics in the classroom.

share|improve this answer

Debugging should be taught because students are humans and humans make all kinds of mistakes, some of which require acquiring some experimental data (debugging info) before any enlightenment regarding a given mistake occurs.

Debugging isn't taught because of the premise (maybe inherited from math department) that programs should be correct by design, perhaps even provably so. And thus students shouldn't be "experimenting" with programming correctly. However this ignores the real world manufacturing process of imperfect humans cranking out software to changing specs under schedule pressures & etc.

share|improve this answer
    
Hmm.. maybe my school is just different, but that's not how things are done at CWRU. –  Billy ONeal Jun 11 '11 at 2:18
    
Probably depends on the historical department inheritance tree of the programming course in question. –  hotpaw2 Jun 11 '11 at 2:24
    
I'm not sure where you're getting all this. All introductory classes spend a few lectures on how to track down bugs. –  davidk01 Jun 11 '11 at 2:45
    
@davidk01 - That doesn't explain the OP's observation, which I've heard, not frequently, but more than once before. –  hotpaw2 Jun 11 '11 at 3:15
    
@hotpaw2: What doesn't explain the OP's observation? Just because students have a hard time learning to debug programs doesn't mean it is not taught which is the conclusion you're jumping to. I've take several programming courses both as an undergraduate student and as a graduate student. In every class the instructor has spent at least one lecture to go over an incorrect program and to fix it in order to demonstrate some common debugging techniques. –  davidk01 Jun 11 '11 at 5:36

It's not so important. I almost never use one, and never have. The best way to debug code is:

  • don't write the bugs in the first place
  • if you do write them, fix them by thinking, not by diving in to the debugger

And for much modern, multi-threaded software, debuggers have the effect of hiding bugs rather than uncovering them. And they should definitely not be "taught" at degree level, any more than one would teach how to use a word processor.

share|improve this answer
6  
I think this one depends. If you're trying to get used to the behavior of a large and poorly documented codebase you didn't write, a debugger is one of the fastest ways to get acclimated with what the codebase is doing. If you're writing all the code, sure, you won't need a debugger often, but not all of us are in that place. +1 –  Billy ONeal Jun 11 '11 at 2:22
1  
@Billy We must agree to differ. You try getting to know a huge MT trading server with a debugger. –  nbt Jun 11 '11 at 2:25
    
@Neil: I've never personally dealt with that kind of thing... but I have debugged MT code before without problems. Perhaps I'm spoiled by MSVC++ -- the debuggers there make showing what the various threads are doing really easy. But if I was debugging in versions prior to 2008 (I think that's when that was added) I could see how that could make things more difficult. –  Billy ONeal Jun 11 '11 at 2:27
    
@Neil: Don't get me wrong -- I'm not saying the debugger is a substitute for thinking, or that it should be the only thing you look at. I'm just saying it's a tool which in some cases can make understanding something easier. If a debugger is causing more confusion, it's generally easy to tell that it's causing more confusion (Because you're getting more confused), and that's when you turn off the debugger and try something else. It's helpful in some cases, but it's no substitute for looking at code/input/output and thinking about what's going on. –  Billy ONeal Jun 11 '11 at 2:32
2  
I know you are flying the face of received wisdom around here. But you are in good company with people like Linus Torvalds, Larry Wall, Brian Kernighan and Rob Pike. –  btilly Jun 11 '11 at 4:15

In most introductory programming courses program state is simple enough that you can weed out any bugs with a few print statements. There also might be the issue of forcing students to do things by hand so they get a sense of how and where in the code certain types of bugs occur. If you have no idea where to look then a debugger is going to be pretty useless.

share|improve this answer
4  
A good debugger is easier to use than print statements. Print statements require that you somehow have a way to serialize your data into a string, which necessitates it's own (possibly bug ridden) code to do the serialization. For example, a linked list program is easy to step through in a debugger, but print statements aren't going to help a student who's trying to write linked list transversal algorithm -- because you'd need that algorithm to write the right print statements. –  Billy ONeal Jun 11 '11 at 2:21
2  
@Billy so stepping through the wrong code is somehow going to help them? –  nbt Jun 11 '11 at 2:27
1  
@Billi ONeal, you're wrong. A debugger you're talking about does not exist. Interactive stepping through the program is only useful when you've already identified the problem with debug logging. Never in my practice (>20yrs) I had to use a debugger with my own code - proper assertions and logging were always sufficient. I'm only using that damned tools with the libraries code and the legacy stuff. And, btw., being able to serialise any data structure into something readable is always a good idea. Some languages/environments gives this for free. –  SK-logic Jun 11 '11 at 11:22
1  
@Billy ONeal, how would you browse a memory of a microcontroller device, attached to a serial port? And, I believe that it is not such a good idea to expose freshers to the low level languages with pointers and stuff before they're literate enough in data structures and algorithms. By that time they'll know how to debug properly. –  SK-logic Jun 11 '11 at 18:27
1  
@Billy ONeal, the most difficult part is in identifying the right moment when to either inspect a value in a debuger (btw., in most cases it is still something like calling a .dump() method, not a direct memory inspection) or to print a serialised value. With a proper debug logging infrastructure in place the problem is narrowed down to an analysis of log files. In most cases a simple grep does the job. No stepping, no conditional breakpoints - just grep. –  SK-logic Jun 12 '11 at 0:47

Tertiary computer science courses are tailored towards teaching students programming fundamentals, as you've mentioned - these concepts are taught to the students in hope that they would grok the necessary concepts and apply it to a wider range of programming languages and problem sets.

Debugging tools, on the other hand, are a subset in the implementation area - each tool is different for each language (even though the concepts are the same). We were exposed to debugging tools but never really covered them in depth. If we spent more than a week on debugging tools, I would look back - in hindsight - and deem that a waste of time. I'd rather learn about BigO notation or polymorphism. However, ff the power of a debugging tool has not been (successfully) conveyed to the students, then that would be an absent necessity.

share|improve this answer
3  
+1. Translated: Because not everybody uses MSVS, GCC/GDB, LLVM/CLANG, etc. –  Billy ONeal Jun 11 '11 at 2:08
1  
+1 although I have to admit I agree with @rerun; A course (or part of one) that goes over basic concepts and tools that are used in a software shop would go a long way towards getting new graduates productive. I've run across several that didn't seem to understand source control even after using it for a while. –  Ken Henderson Jun 11 '11 at 2:10
    
many of the Skills that average developers spend alot of there time with are covered in school. Source Control, Configuration management in general, code exploration, code reading, Build processes etc etc. While I understand that CS degrees need to cover the theoretical aspects I think one senor level class where students worked with a large existing code base find and fix bugs and get it checked in code and "deployed" would make a new developer a lot more useful. –  rerun Jun 11 '11 at 3:27
3  
I totally disagree. If actual code is being written (because writing code is a good way of practising the scientific concepts), then students should have access to good ways of writing that code, and that includes making use of a debugger if so needed. That's not taking away time that could be spend on bigO notation - it is freeing up time that many students spend on bruteforcing their way through minor errors. Nothing much is gained from that. Besides, many other science courses (physics for example) do include practical measurement skills as part of their curriculum. –  Inca Jun 11 '11 at 8:54
2  
Using a debugger requires understanding how the computer works, not just the code. I'd consider this a programming fundamental. I've encountered too many students who just have no idea what their computer is actually doing, and that does not make for a good programmer. –  edA-qa mort-ora-y Jun 11 '11 at 10:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.