Q: What does "Sparse is better than dense" mean? (Python Zen)
Peter Hansen
peter at engcorp.com
Fri Jul 12 04:27:29 EDT 2002
Ian Bicking wrote:
>
> 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.
Good call. I think you must be right about that, relative to the less
useful whitespace issue. Of course, "right" doesn't apply here -- I just
mean your approach is ultimately more useful than one applying only
to ASCII 0x20...
In a trivial way, this also expresses the rationale behind longer
but more descriptive and pronouncable variable names, relative to
the Hungarian notation-inspired and -sired abominations that we still
sometimes see (but more rarely in Python I think).
-Peter
More information about the Python-list
mailing list