[Haskell-cafe] Re: how do you debug programs?

Pepe Iborra mnislaih at gmail.com
Wed Sep 6 12:18:45 EDT 2006

On 06/09/2006, at 17:10, Andrae Muys wrote:

> 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.

You seem to base everything on the assumption that a debugger is a  
program that lets you, and I quote your words below, "trace through  
individual lines of code".

A debugger in the sense that this post regards it is any kind of  
program that helps you to understand a piece of code. A debugger is  
the program that tries to answer the following questions:
"What information can we provide to the programmers about how a  
program is running?"
"What information will help the programmer most?"

If it happens that traditionally debuggers are based in inspecting  
the memory, this is an unavoidable situation considering the history  
of programming languages. But certainly there are many other  
possibilities that can help a programmer to manage the complexity of  
a running program, and it seems as if you disregard them all  
completely in your argument !

> 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?

This whole block is offensive to the rest of the world. Fortunately  
it has nothing to do with reality:
  - the recent GHC survey uncovered "some kind of debugger" as the  
most demanded tool
  - Other functional languages have seen magnificent efforts in the  
debugging camp, such as the awesome Ocaml debugger or the now sadly  
defunct ML Time-Travel debugger from A. Tolmach
  - The Lispish languages, which are arguably on the functional side  
too, have always  enjoyed impressive online debugging tools.

> 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/haskell-cafe/attachments/20060906/a8b36ef6/attachment-0001.htm

More information about the Haskell-Cafe mailing list