Software bugs aren't inevitable

Jerzy Karczmarczuk karczma at info.unicaen.fr
Thu Sep 15 14:30:57 CEST 2005


Steven D'Aprano wrote:
> On Wed, 14 Sep 2005 12:23:00 -0700, Paul Rubin wrote:

>>Every serious FP language implementation optimizes tail calls and thus
>>using recursion instead of iteration doesn't cost any stack space and
>>it probably generates the exact same machine code.
> 
> 
> Are you saying that the recursion done by "serious" languages is a fake?
> That it is actually implemented behind the scenes by iteration?
> 
> It seems to me that if recursion and iteration produce "the exact same
> machine code", the argument for preferring recursion over iteration is
> gutted.

Well, in such a way we can discuss for eternity...
Please, distinguish between the high-level algorithm formulation, and what
computer does under the carpet.

The recursion - as put forward by functionalists is a conceptual way of
thinking. With passing of new parameters without explicitly updating the
variables to which the old ones are assigned. Without loop control
variables, nor looping constructs.
    You don't reassign your variables, you avoid the side-effects. The
programs are often clearer and safer, less error-prone.

Now, the ugly world of basic computing at the assembly level is imperative,
not functional (within standard architectures). The registers ARE
reassigned. The stack must be explicitly handled, etc. You *SEE* explicitly
the iterative structures.

The point of functionalists is that one should avoid that, and leave those
nasty things to the compiler. That's all. Your final conclusion is for me
rather inacceptable. It is not the machine code which matters, but
human effort [provided you spent sufficient time to be fluent in *good*
recursive programming of complex tasks.]


Jerzy Karczmarczuk



More information about the Python-list mailing list