News for hackers. Stuff that matters.
Re:Python 2 will be replaced with Python 3 in the next RHEL ... by irishsultan on Wednesday April 11, 2018 @05:03AM (#16809276)
> I don't know if HN can find any counter-examples, of a language that thrived through an incompatible, code-breaking upgrade.

Ruby qualifies, I'd say. From 1.8 -> 1.9 there were syntax changes, changes to how strings worked and so on. Code written for 1.8 would not in general work on 1.9 and the other way around. While it was possible (sometimes with some extra if statements) to write code that worked on both versions I would definitely call it an incompatible, code-breaking upgrade.

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by Freaky on Wednesday April 11, 2018 @11:41AM (#16812256)
It's notable that 1.9 came with a significant performance boost, so there was a good practical reason to want to upgrade. People were motivated by the prospect of their code running twice as fast - sure, the language was improved a bit too, but it's Ruby, it's already pretty nice, so that was hardly going to light a fire under anyone.

When Python 3 turned up and it was on average slower, my first thought was "well, good luck getting people to adopt that".

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by saurik on Wednesday April 11, 2018 @05:37AM (#16809443)
The fact that it was possible to write code that worked with both wasn't just so critical, though. It allowed you to upgrade your code incrementally to support 1.9 while doing regression testing on 1.8, and then come up with a deprecation schedule for 1.8.
Re:Python 2 will be replaced with Python 3 in the next RHEL ... by rplnt on Wednesday April 11, 2018 @05:45AM (#16809482)
Python could be written that way (2/3-compatible) as well and plenty of programs and modules were.
Re:Python 2 will be replaced with Python 3 in the next RHEL ... by saurik on Wednesday April 11, 2018 @05:55AM (#16809534)
Uhhhh... sort of? I mean, I could go through all of the needless "why the hell did they make this partner incompatible also" stuff like, like removing u'' support (thai was added later), or all of the ludicrous breakage in the underlying APIs (like filesystem calls that made assumptions about character encoding that make no sense for the underlying Unix model and literally caused files to just disappear from iteration)... a lot of this stuff was fixed in later versions of Python 3, but that was years later, making it nearly impossible to deal with the existing land mines of people who had installed Python 3.0-3 (or even 3.4).

But what makes me shocked that you think that that is the case is basic basic stuff... I mean, as one obvious example, they changed the exception syntax. So, "uhhhh.... sure?" it was possible to make a program that ran on both 2 and 3, but it required using "try" with no variable assignment and then digging into Python's exception reflection support to recover the variable. And you had to do this every single time. (And of course a lot of the time the underlying core library would now throw different exceptions, making the situation all the more ludicrous.)

I had code that straddles the 1.8/1.9 boundary of Ruby, and even though I wasn't an expert at Ruby it was trivial to have code that worked for both (and I mean 100% correct: Unicode and everything; remember that neither Ruby 1.9 nor Python 3 added Unicode support, they only made Unicode support easier to obtain. for Python 2 there was already comprehensive, if non-default, support, and for Ruby 1.8 you just needed to be careful about where you did conversions).

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by sametmax on Wednesday April 11, 2018 @07:15AM (#16809921)
Half of the problem you mention are either:

- if you tried to support Python < 2.7.

- if you tried to support Python < 3.3

But nobody used 3.0, 1 or 2. And supporting 2.6 is like supporting ruby 1.7 and 1.8 and 1.9. Which nobody did.

And it's easy to rewrite libs when really the language started to be used in 2004.

Or maybe not, given that "gem install" still regularly crashes on anything other than the top 20 packages, so it's still not a solved issue.

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by opencl on Wednesday April 11, 2018 @07:50AM (#16810169)
Python 3.0 came out in 2008 and 3.3 came out in 2012. Are you really saying that nobody used Python3 for the first 4 years of its existence? I was certainly using 3.1 and 3.2 back then.
Re:Python 2 will be replaced with Python 3 in the next RHEL ... by sametmax on Wednesday April 11, 2018 @07:57AM (#16810213)
Pretty much yes. Some Linux distrib where still using 2.6, and not a lot of them had even 3.2 in their packages.

Only a few like you and me tried it.

I can't recall of any big project or lib ever supporting < 3.3.

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by UncleEntity on Wednesday April 11, 2018 @11:20AM (#16812006)
Blender was using py3k for quite a while before 3.3. I was doing blender dev work back then and can recall the almost immediate upgrades as soon as the newest python release came out -- kind of painful really since I prefered to use the fedora installed version instead of building from scratch so would often stall my dev work until fedora caught up to blender.

They jumped on so early the python devs were saying "WTF are you people thinking?!?"

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by sametmax on Wednesday April 11, 2018 @11:58AM (#16812419)
Given blender is mostly c bindings and a huge code base, it's kinda impressive, and a good example that it's not an impossible task to migrate even a very hard project, let alone the most common ones.
Re:Python 2 will be replaced with Python 3 in the next RHEL ... by UncleEntity on Wednesday April 11, 2018 @12:20PM (#16812665)
It wasn't a migration as much as a bottom-up rewrite of the entire bpy and big chunks of blender itself. Most of the bindings are generated by makesrna at compile (compile compile?) time which is fairly simple once you go deep diving into the sources.

It actually takes a fair bit of shenanigans to get hand-coded bindings into blender, my last(?) patch was bindings for the kdtree and I had to do some convincing to get that accepted. I'd guess that 99% of bpy is generated bindings.

If they stuck with python 2 when they started the initial overhaul they'd probably still be using it since artists are very vocal when their scripts break.

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by dagw on Wednesday April 11, 2018 @08:18AM (#16810327)
Django never had support for python < 3.3 and numpy and scipy only supported python 3.2 and up. The story is similar for most other packages. So if you where using python with any of its major libraries then python 3 was pretty much useless for you the first 3-4 years.
Re:Python 2 will be replaced with Python 3 in the next RHEL ... by collinmanderson on Wednesday April 11, 2018 @12:19PM (#16812655)
Django had support for 3.2 and 3.3, but not 3.0 and 3.1. Django didn't add support for 3.x until it was able to drop 2.5 (Feb 2013).

https://docs.djangoproject.com/en/2.0/faq/install/#what-pyth...

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by icebraining on Wednesday April 11, 2018 @07:05AM (#16809850)
it was possible to make a program that ran on both 2 and 3, but it required using "try" with no variable assignment and then digging into Python's exception reflection support to recover the variable.

What? The PEP that added the new syntax also added it to Python 2.6: https://www.python.org/dev/peps/pep-3110/#compatibility