Why 'Flat is better than nested'

T

Terry Reedy

import this

prints 'The Zen of Python', a poem by Tim Peters that consists of python
proverbs such as "Flat is better than nested." (Others things being
equal) why? Because it is a restatement of the principle of parsimony,
of not multiplying entities without necessity.

Suppose we have a unstructured collection of N items. Organizer comes
along and says 'Let there be structure. Let us organize the items as
leaf nodes in a hierarchical tree' (which is equivalent to nesting). To
do so, we can add as many as N-1 new non-leaf nodes and as many as
(about) 2*N - log2(N) parent child relationships. In other words, nearly
quadruple the number of entities to learn, discuss, and remember. Well,
there had better be a good necessity to do so ;-).

And, of course, once new entities *are* conjured up, it is hard to get
rid of them.
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top