[Haskell-cafe] Re: how do you debug programs?
Andrae Muys
andrae at netymon.com
Wed Sep 6 11:10:07 EDT 2006
On 06/09/2006, at 8:22 PM, Neil Mitchell wrote:
> It's been my experience that debugging is a serious weakness of
> Haskell - where even the poor mans printf debugging changes the
> semantics! And everyone comes up with arguments why there is no need
> to debug a functional language - that sounds more like excuses about
> why we can't build a good lazy debugger :)
>
> [Sorry for the slight rant, but I've used Visual Studio C++ so I know
> what a good debugger looks like, and how indispensable they are]
I simply can't let this pass without comment. It's irrelevant if
you're using a functional or imperative language, debuggers are
invariably a waste of time. The only reason to use a debugger is
because you need to inspect the contents of a processes address-
space; so either you're using it as a disassembler, or you're using
it to examine the consequences of heap/stack corruption.
Consequently, if you're using Java, C#, Scheme, Haskell, Erlang,
Smalltalk, or any one of a myriad of languages that don't permit
direct memory access, there's no reason for you to be using a debugger.
Jon understates it by implying this is a Functional/Haskell specific
quality - it's not. Debuggers stopped being useful the day we
finally delegated pointer handling to the compiler/vm author and got
on with writing code that actually solves real problems.
It's just that historically functional programmers have tended to
already be experienced programmers who realise this. Why would they
waste their time building a tool that no-one needs?
It's a truism to say if your code doesn't work it's because you don't
understand it; clearly if you did understand it, you wouldn't have
included the bug that's causing you difficulty.
Therefore either
1) The code is poorly structured and you need to restructure it to
better represent your understanding of the problem
or
2) Your understanding of the problem is flawed, so you need to sit
back and reexamine your thinking on this problem in light of the
counter-example you have found (the bug).
Spending your time tracing through individual lines of code is
counter-productive in both cases.
Andrae Muys
P.S. It is worth noting that I am here talking about the sort of
debugger raised in the original post. I am not talking about using a
separate tool to extract a stracktrace from a core file in a C/C++
program or equivalent - I'm talking about runtime debugging with
variable watches, breakpoints, and line-by-line stepping.
--
Andrae Muys
andrae at netymon.com
Principal Kowari Consultant
Netymon Pty Ltd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/haskell-cafe/attachments/20060907/8eaddaa7/attachment-0001.htm
More information about the Haskell-Cafe
mailing list