Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Python only just barely survived the jump from 2 to 3.

I really don't think this is true at all.

Python 2 to 3 took a really long time, it was a real struggle, lots of people stayed on 2 for a really long time.

But I really don't think Python was close to dying the same way Perl has/is. There was no risk of Python not "surviving" in my opinion.

There was always a clear way forward and people were actually moving. The mass migration of millions or billions of lines of code from 2 to 3 actually happened and has many high profile million+ line migrations, like Yelp or Dropbox.

There was never anything similar for Perl 5 to 6, totally different situation.





> I really don't think Python was close to dying

It absolutely was. What saved it was:

1. The data science / AI crowd that was gathering momentum any many only used Python 3.

2. No popular alternative. Perl got python as an alternative.

Python was also a good, simple language and had a good healthy culture. But it's nothing sort of a miracle that it survived that biblical software calamity.


You forgot perhaps the most important one:

3. six

`six` was instrumental in repairing the Python schism by giving people a way to incrementally move their 2.7 code to Python 3, and write code that was compatible in both. The six project didn't exist at first and the path to Python 3 was too painful without it. Six solved all that by smoothing over built-in libraries with different casing between versions, incompatible core libraries, the addition of unicode strings, print changing to a function, etc, etc. Perl 5 to Perl 6 (aka Raku) never got that.


Six was one component but not the only one. Python 2.7 also backported a number of early Python 3 features, Python 2 features were reintroduced in basically every P3 version until at least 3.5 (although after 3.3 they were pretty minor), and a lot of extensive migration guides were written (my main bible was eevee's).

In my experience, six was a relatively minor part, and you could get by with your own little compat file for just the stuff you needed, even on relatively big projects. I even found it beneficial to do so because instead of just slapping six.moves everywhere you'd have to re-evaluate some of the old decisions (e.g. at $dayjob at the time we were using all of urllib, urllib2, and requests for HTTP calls, not using six provided strong motivation to just move everything to requests). This also made for a lot less churn when removing Python 2 compatibility.


> Python 2 features were reintroduced in basically every P3 version until at least 3.5

If they had just done this from the beginning there wouldn't even have been such upgrade drama in the first place... like, as an obvious example, removing u'' syntax for unicode strings immediately at 3.0 was just idiotic: if it weren't for some dumb decisions like that one there would have been almost no upgrade discontinuity at all (a la Ruby 2's Unicode reboot, which concerned a lot of people but was a nothing-burger next to the insanity of Python 3).


Sure but importantly they did realise they had erred and course-corrected.

> if it weren't for some dumb decisions like that one there would have been almost no upgrade discontinuity at all

Having been there and done that, nah, the text model changes alone required significant work to square up in most packages. And there were plenty of other semantics changes.


But you could have made those changes incrementally in a way that more cleanly worked across both Python 2 (which already had this split: the default type was just wrong; all of my code, for instance, worked great!... it was just super awkward, as it had tons of u's thrown all over the place). Where they ended up with the language (after, like, 3.7) was much more incremental from Python 2 than the early path to how they got there. To be explicit: it isn't about having to put in upgrade effort, it is about upgrade discontinuity.

As a user, you may not appreciate six, but popular libraries like Django would've never made the jump without six.py;

I’m not talking as a user, I’m talking as a person who ported 350kLOCs of python from 2 to 3.

Django absolutely would have been ported: it was ported without six by Vinay Sajip (building on an earlier work of Martin von Löwis). In fact a limited shim layer was initially committed based on Vinay’s efforts: https://github.com/django/django/commit/5e6ded2e58597fa324c5...

The team ultimately decided to use and re-export six for the convenience of the ecosystem, not out of any sort of necessity.


It's very true, I feel like one of the most useful things python had was stuff like "from __future__ import print_function"

six did help a lot. Didn't help with some things, though, like strings vs bytes vs bytearray.

Python 2.7 was kept very much alive, with a number of small improvements from the 3.x branch backported to it.

Big players, like Django or SQLAlchemy, kept versions both for 2.x and 3.x for quite some time. This allowed for a smooth transition, when all of your dependencies finally had good versions for 3.x.

The difference between Python 2.x and Python 3.x was not dramatic. I would say it was mostly cosmetic up until 3.5 when async landed. Even with these small changes, the splitting of byte strings and character strings alone (an obvious move towards sanity) was plenty annoying for many projects.

Communities and ecosystems are fragile; sharp turns can easily break them.. Even careful maneuvering, like the Python 2 → 3 transition, put very visible strain on the community. A crazy jump that was Perl 6 was not survivable, even though Raku may be a fine language.


> the splitting of byte strings and character strings alone (an obvious move towards sanity) was plenty annoying for many projects.

Python 2 had both, it was a rename, not a split. unicode -> str, and str -> bytes. The "u" string prefix was also removed, which made migration of string-heavy code more of a pain than it needed to be, until it was added back in in 3.3


I was not affected by Py3 at all. First I completely ignored it for five years while it gestated. Then started kicking the tires when 3.4 dropped on a LTS. When 3.6 with better dicts and f-strings landed I moved over with barely a whimper, since I'd had a decade to get things upgraded to 2.7 first.

None of my projects needed to worry much about char encoding, and I'd used logging extensively starting under 2.6 or so.


Porting your own code was relatively easy. The problem was porting all your dependencies, and replacing the ones that were abandoned and didn't support 3.x.

I did wait a bit for Django and SQLAlchemy but it wasn't long, they may have been ready for 3.6. Small deps were replaced or eliminated.

They were ready long before 3.6, sqlalchemy added support for Python 3.1 in 0.6, and Django 1.5 introduced support for Python 3.2 on an experimental basis with 1.6 removing the “experimental” bit.

Long before the AI/data science breakout, we were noticing in our consulting practice (2016-2020) a sharp dropoff in Ruby at startups, and Python as the modal language (by the time I left in 2020, it would have gone Python -> Node -> Ruby).

So no, I don't think AI saved Python; it was fine before then.


2016 already puts one far into the AI explosion. The current hype cycle, with LLMs as a service at the forefront, arguably makes python less relevant than in it was in the mid 2010’s. The current crop of “AI Engineers” can use whatever languages they want for the most part. In 2016 most practitioners were leveraging a lot more of the standard scientific computing frameworks afforded by python.

Python was the lingua franca of data science by 2016, but AI and data science was clearly not the reason startups were building in Django and Flask --- the data science teams were always a morass of Jupyter notebooks and pickle blobs.

> No popular alternative

I can easily imagine a scenario where Julia could have taken the data science crowd and Node.js could have taken everyone else. People like Python, I guess.


Before JS had promises, JS code was plagued with the callback pyramid of doom. You needed an advanced masters degree in masochism to endure that. I don't think Python devs would have liked that.

I don't know. Isn't Python still viewed as a mess now? I was thinking of taking the time to learn it as the best way to write cross-platform utilities, but encountered a lot of negative sentiment about its ecosystem. And all the environment managers you seem to need for it are a turn-off.

Granted, this is coming from a relative noob who read and followed a couple of "how to set up Python properly" articles and that's about it. But I pretty much decided to spend my time on JavaScript, despite its cumbersomeness for implementing simple utilities.


It's vastly improved now. With uv, many times you can download a new utility off GitHub and run it with `uv run foo.py`, including fetching its dependencies.

Cool, thanks!

>Isn't Python still viewed as a mess now?

Imo the coding part is fine. I have no mayor complains about it. I even like indentation as syntax as long as you use tabs :)

Python is the modern day BASIC. Slow interpreted lingua franca. As long as you are ok with its speed I say go for it. Python is the only scripting language where I maintain constant lingering awareness that every single line of code adds milliseconds to run time. As bad as instantiating new variable costing single digit ms on a GHz CPU. This quickly adds up the more you are trying to achieve.

Example benchmark, Python 3.4:

    # Direct Access d['key']: 3.3710 seconds
    # Direct Enum Access d[enum.key]: 157.9954 seconds
In latest versions Enums got "fixed" to "only" 3-6x slower than strings! SimpleNamespace to the rescue.

Its much exaggerated.

Its got a big standard library so you can do a lot by just installing Python. On a lot of *nix systems it will all be installed already. For simple use cases you do not have to have the environment manager.

I have had few problems with virtualenv in any case.

Where you are most likely to have problems is cross platform deployment. If you are going to package it as an exe for Windows users, and package it for major Linux distros, and whatever you need to do for MacOS etc. its going to be a pain. In that case there are multiple languages that might suit you better than JS.


Python is great for data science. Anything where you need to wrap a C library like BLAS, tensorflow, PyTorch, matplotlib, numpy.

It's hot garbage for writing simple cross-platform utilities because of the need for an elaborate environment setup, painful dependency management, and constant compatibility breaks.


Anecdotally, I stopped using python for several years around the transition period from 2 to 3 because a number of libraries I used at the time were in flux with 3 support (beautiful soup I _think_ was one? I could be misremembering). Ironically, I ended up just using perl for a scraping tool instead, which it's quite good at for quick and dirty scraping scripts (PCRE.) Nowadays I use ruby for that type of stuff...

You're contradicting yourself - if Python had no popular alternative, what would have new people used instead and what would existing code have migrated to?

It was close to dying, except for these two things that mean it definitely wasn't close to dying?

"Having no popular alternative" is not something that was close to not happening.


IMO javascript was a valid alternative. Easy to learn and easy to run. That's the main things needed for academic work

Python had a history of tooling/libraries that made it well ingrained into academia


Javascript didn't have the same FFI story with C/Fortran as Python. That's what allowed libraries such as numpy, scipy, pandas, etc. to flourish.

If Golang was around, it might have killed python then I think. To many, the 2->3 jump made little sense. I honestly wish they just started a new language instead.

I still to this day stumble upon code I have to use 2.7 on, thankfully things like pipx make it easy these days. but still,switching back and forth could be a pain.

But you're right, it wasn't like Perl 6. People moved to python and php mostly from perl. what were going to move to from python 2? Ruby?


Python 2.7 was EOL'd at the start of 2020, and serious effort to move from 2 to 3 didn't start until around 2018, by which time Go was a very major player.

I meant when 3.0 was released. By the time 2.7 was EOL'd 3.0 had gained enough momentum to be a viable alternative. It was easier to just migrate to 3.0.

In 2018, I don't know if Go was a major player, both it and rust were still new-ish languages. There was still a concern of being able to hire devs if you used them, where as not so much in the past 4-5 years.


> By the time 2.7 was EOL'd 3.0 had gained enough momentum to be a viable alternative. It was easier to just migrate to 3.0.

~3.8 at the time, not 3.0. 3.0 was a mess.


Major-ish. It was getting experimental module support around 2018; arguably go get was already better than Python's mess, but it wasn't great. It wasn't that widespread in industry yet - we could very rarely hire anyone with a Go background at that point.

Pretty major. I started using Go in like 2009 or 2010 and industry adoption was already pretty wide in the mid 2010s (largely replacing Java moreso than Python, IMO).

> I still to this day stumble upon code I have to use 2.7 on

There's always Tauthon (Python 2.8), lol.


Can you imagine if the PSF had been working on Python 4 in parallel, with more backwards compat shifts or even a radically modified syntax?

I think another saving grace was, when considering Python 3, one's choice was between "easy-ish migration to best in class" and "difficult rewrite into second-best". Meanwhile with Perl 5/6 it was "two moderately hard migrations into metastasized shell-script has-been language" and "difficult rewrite into best-in-class with lots of upside".


The delta between python 2 and 3 was much smaller than the delta between perl 5 and 6. Perl 6 might as well be a totally different langue which is probably why they renamed it to Raku, to stop people thinking that it was the same language.

I know companies with a big Python 2 stack that rather preferred to rewrite in typescript than migrate to Python 3

I turned down one of those companies because I didn’t want to deal with that migration in 2021


I will never forget Mercurial's postmortem on their experience with the Python 3 transition. They had very few kind words to say about the process.

https://gregoryszorc.com/blog/2020/01/13/mercurial's-journey...

Part of me even wonders if the transition had any role to play in why Mercurial gradually lost whatever foothold it had in the DVCS ecosystem.


For the crowd I ran in the lack of real branching and the need to use DirState or Queues for selective commits made Mercurial feel too much like p4, where git felt so freeing, especially with spikes etc...which would be forever in the repo with Mercurial etc...

> This ground rule meant that a mass insertion of b'' prefixes everywhere was not desirable, as that would require developers to think about whether a type was a bytes or str, a distinction they didn't have to worry about on Python 2 because we practically never used the Unicode-based string type in Mercurial.

> In addition, there were some other practical issues with doing a bulk b'' prefix insertion. One was that the added b characters would cause a lot of lines to grow beyond our length limits and we'd have to reformat code.

I wonder if their line length was arbitrarily 80chars or some silly serial terminal like limit.

> It is now 2020 and Python 2 support is now officially dead from the perspective of the Python language maintainers. Linux distributions are starting to rip out Python 2. Packages are dropping Python 2 support in new versions. The world is moving to Python 3 only. But Mercurial still officially supports Python 2

To me it doesn't matter what pain points there were between 2/3, or that it was even python.

That is just the classic way any modernization effort fails. IMHO those failures are almost completely tool agnostic and are cultural failures.


Hindsight is 20/20 but that article definitely makes me question the technical leadership of the project. They chose to write a source transformer (which introduced its own set of issues) rather than update string literals to use b'' syntax because they didn't want contributors to have to learn how to use python 3? And because they didn't want lines to be too long? And because it would break change attribution for the lines in question? None of those reasons sound compelling to me at all, but the author presents them as the correct decision.

Very interesting article.

I too was rather upset about the Python 2->3 shenanigans and I was working on much smaller projects.


Python continued growing fast during the 2 to 3 transition, it was nowhere near dying. It was one reason it took so long, people were starting new Python 2 projects 5 years after Python 3 was released. Only around 2017/2018 the default for new projects kind of became Python 3.

Python 2 was used for such a long time because many modules only worked on 2, which was a direct result of the compatibility being broken. There was a catch-22 for a long time that nobody would upgrade to 3 because nobody else would.

You could really make a business case study (well, a project management case study) out of the Python 2 -> 3 transition. It was a very well executed plan. It started with a clear definition of where they were headed (v3) with some good reasons for the technically minded. But the transition itself was really... really... slow.

It was methodical and deliberate, but slow.

But I think it really happened because developers wanted to move to 3. There was enough momentum and upside for moving to 3 that the Python core developers could keep the migration on track without having to drag people along from 2 -> 3 before they were ready. Making sure that the transition was optional for a long time helped tremendously.

I was quite happy working in Python 2 for a long time and only transitioned over to 3 for new projects or code that I thought would have a long lifetime. This was very much a reason why I moved to 3 instead of to another language.

At the same time, I'm not sure what language I would have switched to for the things I was using Python for... Perl was out as it had it's own disastrous migration. Ruby was an option, but never really hit the general-purpose scripting language mark for me.


It was a plan that obsoleted billions of dollars of working code and wasted huge amounts of time (undoubtedly multiple human lifetimes.)

Actual language standards that multiple stakeholders agree on are a much better approach.

Platforms should absorb pain, not multiply it across all developers that use the platform. (I wish Apple would learn this lesson.)


> It was a very well executed plan.

Uh.. You've started in the middle. Python 3.0, 3.1, and 3.2 were insufficiently compatible to support a migration. If not for the effort to reduce 2 to 3 incompatibility by shipping 2.7 and 3.3, 3 could really have failed. I'd say the initial plan was not so good but then the _replan_ after the first setbacks was good.


I never saw the initial versions as viable versions for production work. IIRC, neither did the authors. Part of what I think was so good about the plan was that it was a parallel track for so long. They didn’t start the process of sunsetting v2 until v3 was ready to take on the migration. The specific steps taken, versions released, that wasn’t what was so good IMO. It was the time scale. This was a good decade long transition. The fact that Python thought it would have that much time to make the transition was audacious, but it was going to take that long. And now we have a better language that has supported many more years of growth.

> Python 2 to 3 took a really long time

It took AdaCore so long to port the plugin system of the GNAT Studio (GPS) to Python 3 (which seems to be a fraction of the whole code base), that even conservative Debian had to remove the whole GNAT-GPS package.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1082332


> There was always a clear way forward and people were actually moving.

I was always of the impression that people were very reluctant to move even though the benefits were clear and the movement not nearly as difficult as people claimed. But I still hear people complain about, for example, how you can't run CPython 2.x bytecode on a modern CPython runtime even though you can't run CPython 3.13 bytecode on a CPython 3.14 runtime, either and that hasn't slowed anyone down at all.


> the movement not nearly as difficult as people claimed.

Original was really rough because the core team had gone in the wrong direction on migration, and the Python io module was hell as well.

By 3.3-3.4 it was relatively smooth sailing but that took a lot of work from the community and core team both (reminder that Python 2.7 was released after 3.1, backporting a number of features to make compatibility easier, and old features were reintroduced as late as 3.5).


I started on 3.2 and found it reasonably smooth (dealing with encodings in 2.x was also not pleasant IMX if you also cared about universal newline support at the same time), but I will definitely cede that 3.0 and 3.1 were Not Ready.

I watched both of these at the time. FWIR Python took some learnings from the Perl experience and it was still close.

I agree

If anything might have killed python it was not python 3 per se but shipping a "beta" version of Py3 as 3.0

Python 3 only got usable really around 3.3 or maybe 3.4


Not sure why this was downvoted, 3.3 was when they started re-adding things that were removed in 3.0, to make supporting both 2 and 3 reasonable for libraries. I think it kept going in both 3.4 and 3.5 with more features, but the 3.3 restoration of the "u" string prefix is the one that I remember.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: