Re: Learning C



On 2006-03-12, Ian Collins <ian-news@xxxxxxxxxxx> wrote:
Richard G. Riley wrote:
On 2006-03-11, Keith Thompson <kst-u@xxxxxxx> wrote:

If I might summarize:

Richard G. Riley really likes debuggers. Not everyone else likes them
as much as Richard does.

I believe that covers all the relevant points.

Next?



Very droll.

But not at all what the crux of this is about : what its about is a
one way of working which can dramatically speed up ones familiarity
with a system. I find it terrifying that there seems to be a fair
number of programmers here who think a debugger is "only for finding bugs"
: it is a limited and naive view.

There is the middle ground, read the code first and step tough bits you
can't sus out in the debugger. A decent source browser (one that
gives

100% of course. *Nothing* is as good as a good clear printout for an
overview and a familiarity. Hell, I print out man pages still.

you callers and callees) is a better tool for the job, it gives you an
overview of the code, rather than the details of one part of it.

Using a debugger as the main tool for familiarising one's self with a
large body of code is a bit like using a microscope to read a book.

I'm afraid that due to some of the replies I might have become a bit
exasperated and come across as a bit of a fanatic :(

But to close and to summarise some points which a lot of posters dont
seem to be aware of - or at least it appears that way from their
"debuggers are only occasional useful" replies -

1) A debugger can give you that high level overview too
2) It has cross reference facilities for definition finding
3) Ability to give symbolic representation to data
4) Ability to tweak at runtime to force unlikely conditions
5) Abilitiy to see entire dataset : not that determined useful by the
original programmer
6) Watchpoints & HW breakpoints to isolate required conditions.
7) Shows types : reveals bad casts & conversions very quickly in the
datawindow.


There are more. A good print out is good if for nothing else than
sitting on the jacks having a read :) Or annotation. The combo of a
good debugger with the experience of how to use it and possibly a
profiler is nirvana for a C programmer working on a large project.

I've seen old systems where the code is simply unreadable :
multistatements per line, single letter variable names, cast city :
code like this can be a nightmare to read from a printout - it is
useful to watch the program run. Yes, printfs* can be useful if
you have the knowledge and the facility to insert them.

(*) Or home brew multi-platform/interface compatible logging system
like Linux's klogd.

One last point about your microscope comment : this is only true if
you *step* every line. You dont. You place strategic break points at
the page or chapter you are interested in : after all, a C program is
hardly a novel - thought it is a schematic :)

And to anyone that got this far that isnt totally bored by the whole
thing : consider this. You see a function in a source browser :
are you not interested in HOW it was called? Why it was called? You can
guess from 30000 pages of printout or from a call hierachy in a source
analysys tool or IDE : but its 2 seconds work to set a break point
there and examine a few call stacks.

Yes, I'm an advocate. And astonished by the claims of some who say
they havent used a debugger more than twice in over 20 years of C programming.



.



Relevant Pages

  • Re: I & J
    ... debugger once. ... wouldn't remotely expect any programmer to know what an oscilloscope, DSP, ... skilled and/or smart person by some arbitrary criteria. ... Your statements about factoring code in C ...
    (comp.lang.forth)
  • Re: introspection in SML
    ... development I did not feel the need for a debugger; ... SML modules were to akin to Python modules, but it was just a wrong ... programmer would use numpy to do vector and matrix computation, ...
    (comp.lang.functional)
  • Re: Newbie
    ... Can you provode a citation? ... If Mr Programmer uses a debugger, Mr Programmer is a bad programmer. ... used - and its not only to "find bugs". ...
    (comp.lang.c)
  • RE: z/OS 1.8 reliability question
    ... machine with a debugger present -- a system that simply cannot find ... I have yet to find a programmer that knows how ... send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO ...
    (bit.listserv.ibm-main)
  • Re: Which is the best open source C/C++ IDE out there?
    ... > I'm not a real programmer, ... > It's a tool based environment. ... > - Compiler with a debugger. ... > IDE vs. Toolbased Environments ??? ...
    (freebsd-questions)