Lost a new commercial user this week :(

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 19 08:24:49 PST 2014


On Fri, Dec 19, 2014 at 03:38:27PM +0000, Daniel Davidson via Digitalmars-d wrote:
> On Friday, 19 December 2014 at 12:52:32 UTC, uri wrote:
> >This is true. The first week for a new developer where I work is
> >developing a better boot loader. The debugger is not allowed during
> >this induction week and as a result our devs learn how to write
> >better code first time through careful planning and understanding of
> >what's going on at the machine level.
> >
> As you beat your chest over your boot loader - consider both this
> example and in general Walter's lack of need for a debugger. Could
> this lack of need be attributable to understanding of the entire code
> base being used?

Nope.

FWIW, I work with a large enterprise project that is far too large for
anyone to grasp in its entirety, yet I don't find debuggers that helpful
either.  Well, they *are* helpful in some cases, just not as many as
people often claim, as least not for me.  The oft-maligned
printf-debugging, when wisely used in a targeted way, is often better
IME because I'm dealing with an embedded environment, where it's a pain
to setup a debugger. Well, it *can't* run a full debugger; the best it
can so is to run gdbserver which I then have to connect to remotely.
Once that's setup, I run into the frustrating problem of gdb being
unable to find the requisite symbols, needing to be in the same
directory as the executable, being unable to locate the source file(s),
being unable to resolve library symbols, ad nauseaum.

With printf (well, fprintf to a debug log, to be precise), I can get a
trace of strategic points in the code in text format that I can peruse
at my leisure, rather than being stuck inside a debugger where rewinding
isn't possible. (Yes, I know gdb has recently acquired rewinding
capability, but that's no help in a tightly-controlled embedded
environment where every tool is locked to a specific version and
upgrading is not an option.)

This doesn't mean that debuggers are *useless*, which is a completely
different statement (and is patently false). Sometimes they can be
useful, e.g., for obtaining a stacktrace from a segfault, or to
ascertain exactly where a function pointer ends up when it's a generic
object that could in theory point anywhere, etc. (though even the latter
can be manually done by inserting an infinite loop into a suspected
target and then using `top` to see if the CPU usage is 100% -- a `kill
-11` afterwards usually also generates a stacktrace that confirms where
it ended up). It's just that debuggers aren't as universally useful as
proponents tend to make it out to be.


> I imagine you don't have many outside dependencies for your boot
> loader. I imagine most of what Walter works on involves an entire
> stack that he has either written from ground up or when pulling
> outside dependencies in has much less surface area to deal with that
> is new to him.

Unfortunately, your imagination isn't quite accurate in this case.


> Contrast that with someone wanting to tie into a framework (vibed) or
> use a sophisticated library (websockets).  Yes, you can stick with the
> "real men don't use debuggers" line, but that is much easier to
> stomach when your outside dependencies are small in scope.

That is a false assumption, based on my experience as described above.


> Isn't one of the best ways to learn a new codebase to step through it
> in the debugger?
[...]

Absolutely not. You'd get lost in the forest *really* quickly and lose
sight of the forest for the trees, especially in a large codebase where
each logical operation may involve a dozen layers of abstraction, and
lower-level code is all generic so you won't easily understand how it
concretely fits into the big picture. For this, I recommend reading the
source code instead(!). That's what the source code is for!!

Of course, none of this implies that we shouldn't work on making D work
better with debuggers; quite on the contrary, I found it very
frustrating sometimes when I *do* need to use the debugger but D support
for that is rather anemic. Fortunately, being a printf-debugging veteran
does help work around such limitations. :-P


T

-- 
Famous last words: I wonder what will happen if I do *this*...


More information about the Digitalmars-d mailing list