News for hackers. Stuff that matters.
Re:Why Python 4.0 might never arrive, according to its creator by dekhn on Thursday June 03, 2021 @09:32AM (#27381038)
The problem is, they are calling it a mistake but they were very well informed of the consequences of doing that they did. Everybody said "just fix integer division and print, finish the migration then start adding new features", and they went ahead and totally ignored that.
Re:Why Python 4.0 might never arrive, according to its creator by chrismorgan on Thursday June 03, 2021 @10:41AM (#27382093)
Eh, the Unicode situation was irredeemably awful in Python 2 because of the era it was of. Fixing that could never have fitted into what you describe. It had to be a significant breaking change, and even if Python 3’s string handling isn’t perfect (its strings are sequences of Unicode code points, not Unicode scalar values, so they can be ill-formed which was madness to allow; I say they should have gone all in on UTF-8 instead, which trades away some sorely misleading, tempting but practically quite useless functionality in favour of performance and memory usage), it’s vastly better than the situation in Python 2, where you pretty much just couldn’t be sure of anything—on many common configurations, you couldn’t even reliably output Unicode, and might not be able to at all without setting the PYTHONIOENCODING=utf-8 environment variable before starting Python, if my memory serves me correctly (I am glad to say that I haven’t had to deal with python2 for five years now).
Re:Why Python 4.0 might never arrive, according to its creator by tobiasSoftware on Thursday June 03, 2021 @08:59PM (#27389288)
In my opinion, the issue was that they used this feature as an excuse to have other breaking features that weren't really needed. I think besides the string upgrade, every other breaking feature should have worked with 2 to 3.

Then they could have had a clear upgrade guide that is to run 2 to 3, then clear explanations on how to fix all the remaining string issues. Instead, I have no clue what 2 to 3 fixes and what it doesn't, leading to "2 to 3 will probably work, but if it doesn't, then you'll just have to figure it out yourself."

That's unacceptable, and as a result caused many libraries to take a long time to upgrade. Personally, I had to spend 10 YEARS to wait to upgrade to Python 3 due to the wxPython library that all of my projects used that took that long to upgrade to Python 3.

Re:Why Python 4.0 might never arrive, according to its creator by tyingq on Thursday June 03, 2021 @10:51AM (#27382231)
True, though that's one of the things that 2to3 couldn't deal with, because it's not possible to do so automatically. It can't have had any idea what was supposed to remain a string, and what was supposed to become bytes.
Re:Why Python 4.0 might never arrive, according to its creator by tobiasSoftware on Thursday June 03, 2021 @09:01PM (#27389302)
My problem was that there were other unspecified things that 2to3 couldn't deal with. Imagine the world where the upgrade guide was to run 2to3 and then it had explanations of how to address the remaining string issues. Instead, I found the attitude of "run 2to3, it'll probably work but if it doesn't, then you'll have to figure it out yourself."
Re:Why Python 4.0 might never arrive, according to its creator by dekhn on Friday June 04, 2021 @11:11AM (#27394377)
yeah, I forgot to include unicode but I actually think they should have completed the print() and integer division change migration (without a major version bump, with import futures) and then done a major version bump (to 3) specifically for Unicode. And I agree- utf-8 has clearly established itself as the preferred encoding.
Re:Why Python 4.0 might never arrive, according to its creator by sophacles on Thursday June 03, 2021 @10:22AM (#27381780)
Whenever I work on a project that gathers interest in multiple places I get input like:

* If you do X you'll fail

* If you don't do X you'll fail

* X is neat but don't worry about it til later.

I imagine that the people in charge of python, a wildly popular programming language (at the time, and still), got all sorts of input, much of which conflicted. They chose a path and it was a bad choice, a mistake. This is clear in retrospect 13 years later, but at pycon in 2008 (a few months before python 3 officially released) the viewpoint was more mixed - a lot of people thought it was a good path and a lot of people thought it was terrible and others still thought the transition plan was annoying but would be cleared up pretty quick.

Re:Why Python 4.0 might never arrive, according to its creator by Blikkentrekker on Thursday June 03, 2021 @10:31AM (#27381937)
It's not so much the issue that it is clear that it was a bad decision. — they admit it, owe up to it, and I do not blame them for making the mistake and admitting it was unfortunate and that they learned their lessons.

What drives me to ire to no end are the many people that defend it on message boards with “Just upgrade; you had ten years.”, clearly not realizing the risks and money involved in such an endeavor.

It's as though the government suddenly start putting something in the water that improves it's health benefits, but will erode contemporary plumping pipes away in ten years and people say. “Just break down your walls and replace your plumbing; you have ten years.”. — it is quite expensive, and risks that my house fall over.

Re:Why Python 4.0 might never arrive, according to its creator by nindalf on Thursday June 03, 2021 @12:11PM (#27383484)
This is a reasonable take, but think about this from the perspective of engineers who've never made any mistakes in their lives. It's hard for them to fathom how anyone else can make a mistake like the Python devs did. The person you're answering clearly had the foresight to know what was the right thing to do, why can't everyone?
Re:Why Python 4.0 might never arrive, according to its creator by at_a_remove on Thursday June 03, 2021 @10:36AM (#27382019)
I started reading about Python long before I began programming in it (partially due to a deeply terrible book on the topic I purchased). I ran across the integer division bit and stopped cold. "That," I remember thinking, "is a language feature they will change."
Re:Why Python 4.0 might never arrive, according to its creator by leephillips on Thursday June 03, 2021 @12:54PM (#27384106)
Is that because you didn’t have experience with other languages? Because integer division in python2 worked in the way I had come to expect from Fortran, etc.
Re:Why Python 4.0 might never arrive, according to its creator by at_a_remove on Thursday June 03, 2021 @01:02PM (#27384197)
No, precisely the opposite: it is because I have tons of experience with many other languages.

I get why some people think a default integer division is a good idea. I do. Having said that, it was clear that Python was aiming itself at being a kind of glue language wherein various functions were obvious, and integer division is not obvious to someone picking up programming for the first time.

If I walk up to someone and ask "What's three divided by two?" I would expect more "One and a half" answers than "Two goes into three just the one time."

Re:Why Python 4.0 might never arrive, according to its creator by tachyonbeam on Thursday June 03, 2021 @10:26AM (#27381854)
As an outsider: what was the problem with integer division?
Re:Why Python 4.0 might never arrive, according to its creator by LeifCarrotson on Thursday June 03, 2021 @10:40AM (#27382086)
Python isn't strongly typed. You got an integer floor operation with -3 / 2 = -2, but -3.2 / 2 = -1.6. This led to errors when floats were expected but integers were possible among your inputs.

In Python 3, it always gives a floating-point result. You can use a floor division operator if you want to round everything (including integers) towards negative infinity.

See https://www.python.org/dev/peps/pep-0238/ for details.

Re:Why Python 4.0 might never arrive, according to its creator by leephillips on Thursday June 03, 2021 @12:57PM (#27384134)
Python is strongly typed, and your examples show the strong (dynamic) type system in action. An example of a language that is not strongly typed would be Javascript, where you can do 1 + "1". In Python, that gets you a typeerror, because Python is strongly typed.
Re:Why Python 4.0 might never arrive, according to its creator by LeifCarrotson on Thursday June 03, 2021 @01:26PM (#27384546)
Sorry, you're right, it's strongly typed but it is not statically typed.
Re:Why Python 4.0 might never arrive, according to its creator by loa_in_ on Thursday June 03, 2021 @10:40AM (#27382087)
In Python 2:

> 20 / 15 = 1

> 20.0 / 15 = 1.3333333333333333

> 20 / 15. = 1.3333333333333333

> 20. / 15. = 1.3333333333333333

In Python 3:

> X / Y is ALWAYS float division

> X // Y is ALWAYS integer division

This was managable in Python 2 but led to lots of float(argument) calls in every function that wanted to do float division. That lead to unnecessary calls, and unnecessary noise in the code.

Re:Why Python 4.0 might never arrive, according to its creator by pansa2 on Thursday June 03, 2021 @10:35AM (#27382005)
Python’s separation between ints and floats is quite weak, so it didn’t make sense for `3 / 2` to give a different result from `3.0 / 2` (1 and 1.5 respectively). Python 3 changed the division operator to return 1.5 in both cases.
Re:Why Python 4.0 might never arrive, according to its creator by AnIdiotOnTheNet on Thursday June 03, 2021 @10:32AM (#27381952)
Unless you come from a programming background where floor behavior is expected for integers, it was strange.

In Python 2: 20 / 15 = 1

In Python 3: 20 / 15 = 1.3333333333333333

To get the old behavior a new operator was added "//"

Re:Why Python 4.0 might never arrive, according to its creator by guenthert on Thursday June 03, 2021 @01:16PM (#27384390)
> Unless you come from a programming background where floor behavior is expected for integers, it was strange.

In all fairness, the C/C++ and Java communities were and are quite substantial.

Of course the rest of us ought to expect 4/3 as the result of 20/15 ;-)

Re:Why Python 4.0 might never arrive, according to its creator by HerrMonnezza on Thursday June 03, 2021 @10:52AM (#27382245)
The issue is that `int(x) / int(y)` would yield an int result in Python 2, but a float result in Python 3. So you had to find all the spots in your code where `/` was being used as an integer division operator and replace it with `//`.

Since Python 2 does not have any form of type annotation, this made the task hard to do automatically and error-prone.

Re:Why Python 4.0 might never arrive, according to its creator by Doxin on Friday June 04, 2021 @08:04AM (#27392758)
Keep in mind that // was added to python in version 2.2a3 along with `from __future__ import division`. This gave everyone almost 7 years to fix up any existing code before the first release of python 3 even happened. 2.7 only got deprecated in 2020, giving developers a total of 18 years to fix their divisions.

I don't know what the PSF should have done to placate people. Keeping a core feature like division confusing like that isn't a good option, and extending support even longer seems ludicrous to me.

Re:Why Python 4.0 might never arrive, according to its creator by jpm48 on Thursday June 03, 2021 @11:16AM (#27382570)
I guess they mean python2 1/2 == 0 python3 1/2 == 0.5 (threw me the first time when I moved as I use this to demonstrate the differences in integer devision in C based languages).