Iterative vs. Recursive coding

J

John Bokma

Bruno Desthuilliers said:
BartC a écrit :

From personal experience : almost nothing worth being maintained. I'm
talking about complex domain-specific applications here - not shell
scripts or todo-lists.

I doubt anyone who codes like that keeps a todo-list.
The code base was an unmaintainable, undecipĥerable mess loaded with
global state (litteraly *hundreds* of global variables), duplication,
dead code, and enough WTF to supply thedailywtf.com for years - to
make a long story short, the perfect BigBallOfMudd. FWIW, the company
didn't last long neither - they just kept on introducing ten new bugs
each time they "fixed" one.

and they forgot to sell that as new features, I guess :-D.
 
A

Aahz

Steven D'Aprano a écrit :

I onced worked in a shop (Win32 desktop / accouting applications mainly)
where I was the only guy that could actually understand recursion. FWIW,
I also was the only guy around that understood "hairy" (lol) concepts
like callback functions, FSM, polymorphism, hashtables, linked lists,
ADTs, algorithm complexity etc...

To some extent, the question here is the definition of "understand" being
used. It probably would be reasonable to say that I have only a cookbook
level understanding of recursion, and the same would apply to callback
functions, FSM, linked lists, and so on. (I mostly think I do really
understand polymorphism and hashtables.)
 
A

Aahz

Realistically, recursion isn't that important in Python. It's
there if you need it, and sometimes useful, but generally not used
much without good reason. In some functional languages, recursion
is routinely used in place of iteration, but Python isn't built for
that. In Python, most of the use cases for trivial recursion
are better handled with iteration or generators.

Depends how you define "important". It's certainly a critical feature
for Python that you *can* use recursion; it's usually the simplest way of
walking a tree structure (such as a directory tree). Python would be an
extraordinarily limited language if recursion were not available.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top