| Store | Cart

Q: What does "Sparse is better than dense" mean? (Python Zen)

From: Ian Bicking <i...@colorstudy.com>
12 Jul 2002 03:00:28 -0500
On Thu, 2002-07-11 at 06:28, Miki Tebeka wrote:
> Although it's in the Humor section I take the Python Zen> (http://www.python.org/doc/Humor.html#zen) quite seriously.> However I can understand what does “Sparse is better than> dense” means.

Tim hasn't chimed in yet -- I bet he's letting us make our own wild
speculations, so that we may attain greater wisdom through pondering :) 
Or maybe his attention is just elsewhere... but I'd like to think that
this is a Zen koan.

Unlike most of the other people in this thread, I always thought of
sparse v. dense as a syntactic/semantic issue.

For instance, I think Perl is a very syntactically dense language.  If
you change one character, you'll probably end up with a valid -- and
different -- piece of code.  Every meaning is being squeezed out of the
available combinations of characters.  This is really coming out with
Perl 6 too, it seems.

Python isn't like that at all -- there's a lot of punctuation that isn't
even used.  There's also a fair amount of redundancy -- for instance, a
colon introduces a block, even though the block explains itself through
its indentation.  

Kind of the opposite of Perl is Lisp languages, but these have a certain
density as well -- they pack all meanings into a single syntax.  E.g.:
(define (reverse x)
   (if (null? x) '() (append (reverse (cdr x)) (list (car x)))))

Doing a binding -- using "define" -- looks a lot like a control
structure -- using "if" -- and that looks a lot like a condition --
using "null?" -- or a function call -- using "car" -- and the return is
implicit in the expression itself.  One syntactic notion -- the
space-seperated nested list -- is used to do absolutely everything. 
Python, while not nearly as regular, has an eclectic nature to the
syntax that makes different concepts easier to distinguish from each
other.

I'm probably reading more into this little statement than is there.  But
to me this makes sense in thinking about interfaces and other parts of
programming -- being too eclectic or too consistent both serve to pack
too much meaning into too little space.  So for instance, I don't use
the dictionary interface for every mapping-like situation.  But I also
don't think it should never be used.

  Ian

Recent Messages in this Thread
Miki Tebeka Jul 11, 2002 11:28 am
Peter Hansen Jul 11, 2002 12:24 pm
Mark McEahern Jul 11, 2002 01:07 pm
Aahz Jul 11, 2002 06:35 pm
Mike C. Fletcher Jul 11, 2002 08:23 pm
Andrae Muys Jul 11, 2002 11:30 pm
jep...@unpythonic.net Jul 11, 2002 11:45 pm
Peter Hansen Jul 12, 2002 03:31 am
Ian Bicking Jul 12, 2002 08:00 am
Tim Peters Jul 12, 2002 08:22 am
Bernhard Herzog Jul 12, 2002 07:09 pm
Peter Hansen Jul 12, 2002 08:27 am
Messages in this thread