On Fri, 3 Jan 2003, Alexander Maryanovsky wrote:
>
> >Hi Alexander! Next time please delete the rest of the message - it was
> >quite long.
>
> Ok.
>
>
> >As much as a code can be well-thought and well-designed, there can always
> >be typos and things you did not thought about. A misplaced operator, two
> >consecutive if's instead of one nested in the other or vice versa. A
> >missing if altogether. And it can happen while your program is in the
> >1000's iteration. Would you like to analyze a log of N*1000 lines?
>
> Those are exactly the trivial mistakes I wastalking about - they are very
> easy to catch with a println because it's immediately visible that some
> variable's value is incorrect. As for analyzing a log of N*1000 lines - why
> would I do that? The language has a beautiful mechanism for conditional
> printlns:
> if (controlVariable != expectedValue){
> System.out.println("error on iteration "+i+". var1: "+var1+" var2: "+var2);
> Thread.dumpStack();
> }
>
I don't think I agree with you here. OK controlVariable does not have
expectedValue somewhere - but why? With an interactive debugger you can
step the program statement by statement and see where exactly the value
was changed. You can also sometimes set a watchpoint and then just run the
program to the exact place where it happened.
With using println's you'll need to set up a lot of them. Sometimes I do
just that, and it helps me, and then I need to remove them all. (or use
#ifdef DEBUG ... #endif beforehand). But gdb is helpful more than not. An
improper value can originate from anywhere in the program, and an
interactive debugger help you spot the exact location without turning it
inside out.
> The only thing that is hard to debug in Java (and in any other language) is
> multithreading, with or without a debugger. I avoid multithreading bugs by
> being 5 times as careful about multithreaded code as I am about single
> threaded code.
>
Agreed. Debugging Multi-threaded applications is very painful. We wrote
the IP-Noise arbitrator in Perl using multiple threads, and I think we
usually used print's then, and it was quite straightforward. Then when we
converted everything to ANSI C, gdb gave us a lot of trouble. (I think gdb
has some multi-threading bugs). Plus synchronizing several concurrent
threads is very delicate and prune to errors.
Regards,
Shlomi Fish
>
> Alexander Maryanovsky.
>
>
> =================================================================
> To unsubscribe, send mail to [EMAIL PROTECTED] with
> the word "unsubscribe" in the message body, e.g., run the command
> echo unsubscribe | mail [EMAIL PROTECTED]
>
----------------------------------------------------------------------
Shlomi Fish [EMAIL PROTECTED]
Home Page: http://t2.technion.ac.il/~shlomif/
Home E-mail: [EMAIL PROTECTED]
"Let's suppose you have a table with 2^n cups..."
"Wait a second - is n a natural number?"
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]