Debuggers...

Warning: the following will be relevant to software developers only. Ignore this post if you aren't one :)

I wish universities offered a required course on debuggers for those in Computer Science program, or at least made the use of the debugger a mandatory task in a heavy-programming course.

Debuggers are fairly simple to use, yet for some reason many programmers still rely on printf statements to do most of their debugging. I think that debuggers course would help students
appreciate debuggers. And, IMHO, that's the key - appeciating a debugger, and realizing that it's usually more efficient than using printfs ! Most students probably don't recognize true capabilities of a good debugger, and how much it can do for them. For example did you know that you can create a watch and have the debugger breakpoint when some variable attains a certain value, or that you can set a conditional breakpoint so that a debugger only breakpoints on a line if a certain condition holds true ? Modern debuggers even allow you to change code on the fly during debugging session - how cool is that ? And in Java, you can connect your debugger to an already running program. Amazing !

So next time you want to insert a bunch of printfs into your code in order to find that nasty bug, ask yourself - "Wouldn't it be easier to use a debugger?" Or, if you are trying to understand a piece of code that you haven't seen before, trace it with a debugger - the learning process will be so much easier !

Comments

Alex Pilchin said…
Well of course there are a lot of things you can do with a good debugger, but there are times where printf's and logging are more useful and possibly the only realistic tool.

For example you have a complex multithreaded app that runs for a long period of time and at some point during some operation it can crash; it will be very difficult for you to try to recreate such a problem with only your debugger ... often enough such a problem arrises only under extremely rare conditions. In such a case if you don't have logging and your printfs, it will be next to imposible for you to find out what happened. However with good logging you can often figure out the problem just by reading the log entry. This I'm speaking from experience.

Therefore it is useful to know both methods and to find a good balance between the two.

Anyways, you can do everything you've suggested in C++ as well and much more. One good debugger for use in Linux is called TotalView. There you can attach even remote processes! It has good support for multiple processes, multithreading, can lock threads and change the Program Counter in addition to everything you've mentioned.

I don't think that such a course would be good in a good university cause a lot of the features and material can be learned in a few weeks. But I could see something like this being taught in an IT college.

Alex
I always see people bring up that argument - something can be taught in a few weeks, so it shouldn't be taught in University. BULLSHIT ! Half the people who graduate with a CS degree, can't code because coding isn't really taught at university, and hence we get tons of shitty programmers. Theory is good of course, but we are supposed to be programmers, we are supposed to know how to code, and how to debug..
Alex Pilchin said…
Well, you tell me what you would fit in a course like that and there better be enough material for a 4 month course! And it better be a university level course, not some tutorial in a debugger that every kid can get an A in ... I doubt you can do better than a course that can teach you how to use MS. Word!

Also, I would HIGHLY disagree with you with regarding universities not giving students enough opportunity to code! University of Waterloo for example is very flexible and there are enought courses there where you do pure coding, if that is your wish, and there are also some others where you do other things, like design, theory, specs, information system, etc. It is really UP TO YOU to pick the courses you are interested in and learn from them!

I think if a student comes out of a university and can't code then its because he avoided these courses in the university. Also the coop program is highly helpful in providing you with the coding skills you need.
When a person gets a CS degree, it's is reasonable to assume that he knows how to code and debug. And since UW CS graduate can graduate without taking any 4th year programming courses, it is safe to assume that UW CS program isn't good enough.
Alex Pilchin said…
Well, I don't see why these assumptions should be made. There are a lot of different fields and paths in Computer Science.

One mistake you are making is assuming that Computer Science == Programming, but that is not true! Computer Science, in fact, is a lot more than programming and is more theoretical then programming which is why there are a lot of options in the university to take the theoretical courses, which I find in general are quite valuable and can often be applied in programming.

In any case you shold not make any assumptions about a general degree such as Computer Science. The proper way to evaluate someone is to have a look at the courses he/she have taken along with other work experience.
Diego Matute said…
I don't know if learning to use a debugger merits its own course. But its a good point that more people should be using it. It could be something taught in 1st year CS tutorials or something as an alternate way to debug code. I think that would encourage students early in university to use debuggers, instead of discovering them independently.

I don't know if being a good programmer is the final goal of everyone in CS, but it is something that is not stressed enough in the coding classes. There should be more care to stress good programming practices within these courses.

Basically more care should be taken when teaching the core CS courses to stress the importance of good clean code and how to manage it, maybe the theory isn't enough for students to make the connection. Better tutorials, more emphasis in class, scoring based on these criterias are some ways this can be done.

Popular posts from this blog

The wonders of photography...

Trip to Santa Barbara and Los Angeles