http://qs321.pair.com?node_id=996669


in reply to When my script doesn't work, I ...

I'm always surprised when I hear someone's never used the Perl debugger. But then again, I wrote assembler on and off for the first eight years after I graduated from Waterloo, and the only reasonable way to debug assembler is with a debugger, single-stepping through to confirm what's happening is what you meant to happen. (First was 6809 and 68000 assembler, and after that, x86 assembler for DOS on the IBM PC, for TSRs and my own function library. Good times.)

As a bonus, perl -de 1 lets you try out *any* Perl code you want. You can even pull in modules you want to try out and write some code on the fly. But that's the way I work -- not everyone develops the same way.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re^2: When my script doesn't work, I ...
by fisher (Priest) on Oct 02, 2012 at 09:49 UTC
    I'm always surprised when I hear someone's used the Perl debugger. First of all, please don't mention debugger in assembler context. Because, well, in those days debugger tool was 'a-must-have tool'. Nowadays I think it is not.

    In general case, you need a debugger to see a) control flow and b) variable state. In modern reality when it is simplier to edit script file and add some 'print' statements to see both (a) and (b) I see no need in debugger at all. Again: it is true only for high-level programming, for language interpretators, and possibly false for C language, for example. Especially for gcc -O2 =)

    More deeply, I think it is a best practice to make -- as many as it is possible -- of your functions to be side-effect free and test them using QuickCheck (haskell), PropEr (Erlang) and mix it up with unit testing, Test::More at least. And again, the state of variable data you can always print out turning on some 'DEBUG' macro or alike.

    Please nota bene -- I have no intention to offend you. And I, for sure, can be wrong.

Re^2: When my script doesn't work, I ...
by eyepopslikeamosquito (Archbishop) on Oct 02, 2012 at 00:10 UTC

    I'm always surprised when I hear someone's never used the Perl debugger.
    It seems the list of someone's (who dislike debuggers) includes: Larry Wall, merlyn, and Linus Torvalds. :)

      Don't forget Kernighan and Pike... Looking for their quote on the topic, I came across this page, which immediately follows their quote by also adding Bob Martin to the list, with Bob having commented that "Using a debugger is a code smell."

        I'm not nearly as bright as any of those guys, but I want to make sure there are no misunderstandings when it comes to what the code is doing. Tests are awesome, but sometimes running code in a debugger will reveal subtleties that a log message doesn't. Once the compiler's happy with the code (as well as lint (C) or perlcritic (Perl) and everything looks fine in the debugger, I'm happy.

        Alex / talexb / Toronto

        "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds