1. RE: Eu's poor design - recursion

Lucius Hilley wrote:
> 
> 
> I don't care for recursion.  I've used recursion a few times.
> Very successfully.  very pretty. Turns out I've decided recursion
> is a bit of a black art.
> 
> I've trained myself that recursion is bad.  I avoid recursion.
> I use loops... iterations where possible.  I use recursions when
> I know the depths are very much controlled.  A max of 1 or 2
> depths of recursion and I get to avoid dealing with my own stack.
> There we go.. Good recursion.
> Massive recursive depths.  Yeah. pretty, elegant.  Bomb out with
> serious overhead.  I think not.  You can have your recursions.
> I'll stick to my for loops.
> 

It is somewhat slower building massive & deep trees with recursion, but 
this has to do with the shape of the produced tree rather than 
recursion, I think.  (If avoiding recursion, then I would avoid nesting 
the levels of the tree also.) In general, recursive algorithms work very 
well in Euphoria -- I've never "bombed out" and making a tree with 
dozens or hundreds of levels is not uncommon.  Now if you're talking 
about tens of thousands of levels, then you're going to have to deal 
with overhead no matter how you do it.  Don't know why anyone would make 
something a harder problem by avoiding recursion other than to get that 
little extra bit of speed (what you're really avoiding is nesting).  
Certain problems are solved easily and naturally with recursion, but you 
have to jump through hoops without it.  Why jump through hoops?

In a purely functional language like Haskell, you use recursion for 
practically everything.  Functions that take several lines in most 
languages (although less usually in Euphoria) will often only take a 
single line in Haskell.

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu