←back to thread

317 points est | 1 comments | | HN request time: 0s | source
Show context
blindseer ◴[] No.17448804[source]
My biggest problem with this change (and dataclasses) is that it is not backward compatible (I know that a backport of dataclass is available, but it is only for Python 3.6). Can people tell me how they deal with this? Are you using features that are only available in the version of Python all your colleagues / users have access to? Are you using the latest version of Python and hoping your colleagues and users can upgrade to that version of Python?

One main reason in my opinion as to why Python 2.7 stuck around for so long was that everyone agreed that it was the last stable version of Python 2, and the devs could make Python 3 changes without worrying significantly about backward compatibility. I've been using Python3 since Python 3.3 but have had to write code that was Python 2 compatible for large code bases for about 5 years because I knew colleagues / users of my packages would not upgrade. This meant using a select subset of features in Python 3 that had been backported to a version of Python 2.7 that I knew I could get my colleagues / users to upgrade to. It has been great to watch the language evolve and Python 3 really gets a lot of things right, but adding breaking syntax features every minor release is extremely annoying. I have to have a mental checklist of all the different possible subsets of features I have access to given a minimum version of Python I want to support. I've spent the last couple of years in my professional career converting large Python 2 only code bases to Python 3.3+. But if someone wants to use async, I need to bump the minor version. If someone wants to use type hinting I have to bump the minor version. If someone wants to use f-strings I have to bump the minor version. If someone wants to use data classes I have to bump the minor version. It's nuts (to me anyway)!

This sounds rant-y but I genuinely want to know what other people are doing to mitigate this. I love Python! I have spent years advocating its merits. But thinking about large codebases in Python just worries me and the future doesn't look promising here. Are Python developers hoping that once 2020 arrives they'll have a stable Python release and work on Python 4. We'll have the Python 2/3 split all over again!

My personal opinion is that Python needs an officially maintained translator for the latest Python features back to older versions. My current favorite package is py-backwards [0] but it is rather unmaintained at the moment.

[0] - https://github.com/nvbn/py-backwards

replies(5): >>17448827 #>>17448911 #>>17449596 #>>17451139 #>>17452566 #
marcus_holmes ◴[] No.17448827[source]
A bit off-topic, but I'm really curious. Why do people not upgrade Python and stick with 2.7?
replies(9): >>17448838 #>>17448856 #>>17448859 #>>17448861 #>>17448875 #>>17449153 #>>17450668 #>>17450749 #>>17451572 #
dwheeler ◴[] No.17450668[source]
A lot of the problem is that originally the developers of Python made it absurdly difficult to transition from Python 2 to Python 3, and thus the costs far exceeded the benefits. It was historically difficult to write code that ran in both Python 2 and Python 3. If you wanted to transition to Python 3, you had to simultaneously transition every file in your program, every library you depended on, and all libraries they depended on transitively, to Python 3. The "2to3" program was supposed to automate, but this never worked reliably, and cannot work reliably - to do that reliably requires type information that is typically unavailable in Python.

Things have gotten much better, thankfully. Python 3 (and 2) have been tweaked over the years to make it much easier to write code that will work on both Python 2 and 3, and to make it easier to tweak existing code so that it will work on both. As a result, it's possible to transition code a file at a time, or even a portion at a time, instead of the impossible "all at once" transition. Almost no one used Python 3 after it was released, or for a number of years later. Now that the developers of Python have started to make transition practical, people have started transitioning.

Still, it takes real effort to transition to Python 3, and many people have "real work" to do instead of transitioning language versions without any real benefit. "3 is larger than 2" is not a real benefit. A real benefit is something like "this transition will radically increase performance" - and no one is claiming that Python 3 has a real-world advantage like that over Python 2. "Python 2 will eventually be unsupported" is a problem, but no one is providing free money to do the transition, so for many people it's just a fact.

Historically Python has been very good about supporting backwards compatibility and smooth upgrades. I hope that the Python 2->3 transition was an anomaly. You can make changes to languages, but you have to make it easy for users to do the transition.

replies(2): >>17451239 #>>17453970 #
1. ◴[] No.17451239{3}[source]