Perl is worse! (was: Python is Wierd!)

Gareth McCaughan Gareth.McCaughan at pobox.com
Sat Jul 29 09:52:46 EDT 2000


Steve Lamb wrote:
>>> it is 1 and it can be all of those all on context.
> 
>> In Python, and most programming languages that have some notion of type,
>> it is an integer.  If you wanted a string, then you'd have typed '1', or
>> converted it to a string with `1` or repr(1) or str(1).
> 
>     Most, not all.  Again, I ask, as a /human/.  Not as a computer,
> calculator, dog, fish, pet rock, face on mars, some gas creature in
> delta-theta 3 (word up, gass monster) or almond, is 1 a character a string an
> integer a floating point number or what?  If you have problems ask about 2
> dozen people off the street what 1 is with that question and see how many
> puzzled looks you get.

If you ask them "Is 1 an integer or a string or a character or
a sequence"? Yes, they'd give you strange looks. Mostly because
they wouldn't know what you meant. If you went up to 24 people
in the street in, say, London, and asked "Un loup, c'est plus
comme un chien ou comme un chat?"[1] they'd mostly be baffled
too, for the same reason: they wouldn't speak the language.
Likewise if you asked them a technical question from some
other discipline (sticking to ones that somewhat resemble
the question you asked, consider "Is 1 an equivalence class
under equipollence, or a von Neumann ordinal, or something
else?", which would make excellent sense to a mathematical
logician).

Conclusion: Asking technical questions of random people on
the street is a poor way to get useful answers.

                           *

Deciding what things mean according to context would be
very cool if any computer could really do it the way people
do. Unfortunately, they can't. The approximations they
*can* manage are simple enough to mean that they break
sometimes, and complicated enough to make it hard to be
sure whether they're going to break. This is not, for
me at least, a good combination.

It's nice, sometimes, that Perl can use a "123" found in
a string and use it as a number. But the downside of this
kind of guesswork is that instead of having to remember
to say "this is a number" when you get hold of it, you
have to remember whether you're dealing with a number
or a string when you do comparisons, and that sometimes
(I've mercifully erased the details from my brain) you
need to add 0 to an object just to make *sure* Perl
treats it as a number, and so on and so on. This works
OK for small programs, where most of the time it guesses
right and when it doesn't there isn't too much code to
dig through. It's much, much nastier when your programs
grow beyond a few hundred lines.

                           *

[1] Pardon my dodgy French. Anyone whose French is even
    dodgier than mine may need to be told that it means
    "Is a wolf more like a dog or like a cat?". The fact
    that most people in London wouldn't understand the
    question doesn't mean that the distinction is meaningless
    to the average person.

-- 
Gareth McCaughan  Gareth.McCaughan at pobox.com
sig under construction



More information about the Python-list mailing list