[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Zen of Python
Avi Bryant wrote:
> ... Languages
> like Scheme and Smalltalk, on the other hand, are both quite succint and
> extremely regular and explicit, far, far, far more so than Python is.
Aside from macros, I see nothing in Scheme that is particularly succinct
compared to languages like Perl and Python. There are particular
primitive forms that are succinct (e.g. "if") and others that are not
(e.g. (- 3 4) is 5 tokens). Scheme is also very picky about the
distinction between lists and other sequences so that you must do a
vector->list. I'm not saying anything is wrong with Scheme. I just
wouldn't call it particularly succinct.
> I think you're conflating two things here: one is how succinct a language
> is, the other is how regular.
The problem with your examples is that it is Perl/Ruby that is regular,
not Smalltalk. Perl/Ruby combined their normal rules for operator
combination. Smalltalk made a special-case method to handle that
particular problem. The Smalltalk way will increase the regularity of
code by encouraging a single idiom, but it will did not increase the
regularity of the language.
Nevertheless, it is true in general that Perl has many special cases.
And most of them are added in order to improve succinctness.
> Lisp has a very similar combination of regularity and power. I don't know
> what the equivalent Lisp idiom would be, if there is one, but you
> certainly could write a function that allowed something like
> (hash-ref dict 'foo' :if-absent-put (lambda () 42)).
In what language could you NOT write such a function?
> What's the equivalent Python idiom? My guess is that it will be either
> less regular, or less explicit, or both. I'm not trying to pick on
> Python, I'm just trying to point out that there is no simple relationship
> between regularity, explicitness, and succinctness; it's entirely possible
> to have all three.
The Python name is not as clever as the Smalltalk one, but the semantics
seem to be the same:
You're trying to say that succinctness can be added in a readable way or
an unreadable way. That is true for some examples. But there are also
examples where you can get more succinct if you, for example, make an
argument implicit. Perl is full of that stuff. I think if PaulG spent
some time in a language where succinctness was taken to an extreme he
might reconsider it. ;)
Remember also that PaulG said that you can just add succinctness to the
language and people can fall back on the verbose stuff if they prefer
it. That decreases regularity:
"One reason it's hard to imagine a language being too succinct is that
if there were some excessively compact way to phrase something, there
would probably also be a longer way. For example, if you felt Lisp
programs using a lot of macros or higher-order functions were too dense,
you could, if you preferred, write code that was isomorphic to Pascal."
This does not take into account that the person who makes the decision
is usually a different person than the one who pays for it. (except when
you can't read your own code!) Plus there is a price in just knowing
that there are two ways to do it. Plus, one way of making things
succinct can often be to violate a core tenet of the language (for
instance a Schemer might feel that making vectors auto-convert to lists
would do so).
PaulG's particular examples are somewhat different. There is an
over-head cost in using macros and higher-order functions. That makes
them much less prone to abuse than short-cuts embedded in the language