🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.logo
Article #249

Re: um, maybe this is a silly question

#249
From: Brian Harvey
Date: Mon, 12 Oct 1992 18:14
29 lines
2339 bytes
smith@sctc.com (Rick Smith) writes:
>I suspect the "right" way to teach programming is to start with
>recursion as the essential iterative technique, and then teach
>how to convert from recursive to iterative as an engineering task.

Not to beat a dead horse, but I really think the alleged dangers of recursion
are overstated.  It may be a problem if you're programming on an 8086 that's
limited to 64K of stack space, but on any real computer, if you have a memory
problem you probably also have an even bigger problem about execution time.

To a first approximation all algorithms are either like searching or like sorting.
If your algorithm is like searching, and you're running out of stack, you're using
a linear algorithm.  If you switch to a log-N algorithm, you'll have plenty of
stack space, unless the size of your problem is very different from what most of
us face.  If your algorithm is like sorting, then you'd better be using a
divide-and-conquer method, in which case you need the stack space whether you
like it or not.  You can go to a lot of trouble to use non-recursive control
structures, but only by building your own data stack by hand, and that won't
help with the space issues.

If you describe recursively an algorithm that's really a loop, then your C
compiler will implement it iteratively.  (You *are* using gcc, aren't you?)
If not, then the technique of recursion elimination will still require a
stack, and not much is saved.

I do agree with the part of the message that says that programmers have
to be trained to learn to think recursively.  That's why colleges should
use Abelson and Sussman as their intro programming course, and high
schools should use Logo!  :-)
Technical Details
Message-ID: <1bcfa5INN4bs@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!ukma!wupost!darwin.sura.net!spool.mu.edu!agate!anarres.CS.Berkeley.EDU!bh
References: <1992Oct11.192128.5448@netcom.com> <1ba7vcINNpam@agate.berkeley.edu> <1992Oct12.163421.24051@sctc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!ukma!wupost!darwin.sura.net!spool.mu.edu!agate!anarres.CS.Berkeley.EDU!bh
From: bh@anarres.CS.Berkeley.EDU (Brian Harvey)
Newsgroups: comp.lang.logo
Subject: Re: um, maybe this is a silly question
Date: 12 Oct 1992 18:14:29 GMT
Organization: University of California, Berkeley
Lines: 29
Distribution: usa
Message-ID: <1bcfa5INN4bs@agate.berkeley.edu>
References: <1992Oct11.192128.5448@netcom.com> <1ba7vcINNpam@agate.berkeley.edu> <1992Oct12.163421.24051@sctc.com>
NNTP-Posting-Host: anarres.cs.berkeley.edu