PEP0238 lament

Stephen Horne steve at lurking.demon.co.uk
Mon Jul 23 21:28:48 EDT 2001


On Mon, 23 Jul 2001 17:05:34 -0500, <mcherm at destiny.com> wrote:


As we agree on the final conclusion, going through this again is
probably merely annoying, but there are some things I want to set
straight.


>> 1/2 == 0.5:
>>    Perl -- untyped, thus irrelevent
>>    LISP -- academic language only
>>    Pascal -- the Ada folks thought it was wrong
>>    Modula 2+ -- Minority languages
>>    JavaScript -- dumbed down language
>> 1/2 == 0:
>>    Visual BASIC -- most used language 3 yrs running
>>    C -- what need I say?
>>    C++ -- ditto
>>    Java -- ditto
>>    Ada -- intentionally changed the Pascal practice
>>    VBA -- most used non-programmer language
>
>Now, I *could* argue with you. I could say that VB, C++,
>and Java are just imitating C, and thus you only have 2

In the C++ and Java case Yes - they *stayed* with the existing system
despite the fact that particularly for Java, they are different
languages and free to change - and Sun were specifically seeking ways
to tidy up the language and make it clearer, simpler and less error
prone yet they kept division as it is.

VB is based on BASIC, which has a variable history but which in the
early days generally did 1/2 -> 0.5, and generally *changed* it later
on.

Notice how any case where language designers have made a deliberate
change, the only way they change is towards 1/2 -> 0?

>I could say that mere put-downs of excellent languages
>like LISP and Modula 3 (and other languages, like JavaScript)

I'm not putting them down - they are all excellent and important
languages as I said. But if we are considering what most people are
going to expect after coming to Python from other languages, we *have*
to acknowledge both the relative scales of use, and the experience
implicit in the way language families have evolved over time. We also
have to consider the languages reputations for clarity etc - a much
shakier and porobably losing issue if you compare C family with Pascal
family languages - but looking at the evolution of that specific
aspect is a pretty strong indicator reguardless of the wider nastiness
of C and BASIC derived languages (and yes, my main language IS C++).

LISP doesn't aim to be a language for mainstream applications - it
does what it set out to do extremely well (if cryptically) and it's
success in its target fields is the very reason we have close
derivatives like scheme, besides many principle-borrowering languages,
today (but it's *still* a wierd choice for editor scripting ;-).

Wirths languages don't have users on the same scale as C et al, which
is a great shame as they are far superior languages (bar their wierd
view on division ;-) - but those user bases are still pretty secure
with good reason.

The continued existence of Pascal in the form of Delphi is, to me, a
freak of history - Delphi as a Modula 3 based language would have been
a far superior thing, especially if it adhered to the relevant
language standard, but Borland had Turbo Pascal to hand at the time
and a huge community of users that it chose not to discard by breaking
their existing code and experience - thus Pascal is still here despite
being a freak of history, whereas the far superior Modula series have
much smaller user bases. Sound familiar ;-)

>On this point I'm holding my ground. I do NOT belive that
>int division is "the same thing" (with different domain). For
>instance a VERY IMPORTANT feature of "division" is that
>(A / B) * B == A, and "integer division" doesn't maintain

Neither does float division. (1.0/3.0)*3.0 -> 0.99999999999999
(for decimal floats - similar binary principles apply).

That difference is small enough to be hidden until it's too late to
fix - much rather the blatantly obvious bug than the subtle hidden
one. This is exactly the kind of issue that is supposed to be
bread-and-butter to numerics programming, BTW, and exactly the kind of
thing students should be taught to be aware of.

>this. Another clear way to tell that "integer division" is
>different from "division", is to see that they give different
>answers... 25 <int division> 3 == 8, while 

Yes - and matrix division gives different answers again. Do we want a
different operator for that too?

The real people to ask are mathemeticians - they have accumulated
thousands of years of experience, and they represent integer and float
(and symbolic and finite field and matrix and so on) division using
exactly the same selection of operators. We can't use the same
representation until we finally drop ASCII as our source file format
and switch to XML with user-configurable presentation for standardised
entities (oops, fantasy world again) - but we can follow the same
principle that thousands of years of the worlds mathematicians
experience - and several decades of the bulk of the worlds programmers
experience - have clearly indicated to be the preferred choice.
Division is essentially the same thing irrespective of the data type.


There are *much* better reasons than these not to change division, but
they are certainly good enough to show that 1/2->0 is an extremely
strong contender for the belt - not some pretender that can simply be
ignored - and that even if the change goes ahead, and even when the
bugs are fixed and everyone has forgotten the agony of PEP0238 - there
are very good reasons to believe that Python will *NOT* be better for
the change, but that it will be *worse*.

I cannot prove that the change is for the worse, but I have raised
very good reasons to consider it highly likely and I have proved that
scepticism over PEP0238 is valid - both because and irrespective of
backwards compatability. And I have explained my position with regard
to my past Python advocacy and the very difficult position this is
going to leave me and other advocates in.

How do the pro-PEP0238 people react? Lets see...

1. Some continue to refer to float division specifically as "correct"
   division - not as a preference, a convenience for particular
   applications or a crutch for students. By implication, mine and
   other peoples rationally stated opinions are *incorrect* and
   we're stupid for even thinking them.

2. Others write off strength-of-feeling as irrationality and
   same-old-usenet, and they state that these are the same old
   arguments as if a viewpoint that is repeatedly and emphatically
   raised by many people with rational arguments is somehow inherently
   invalid.

3. The most important people have simply said very little bar a few
   easily countered viewpoints that they seemingly have no intention
   to bother discussing further. They have spoken and that is the
   end of it.

Let's take a guess for tomorrow...

4. If you don't like the message, keep on flinging mud at the
   messenger.

Anyone resent the insult? - so why should I take it?




More information about the Python-list mailing list