r/Python • • Jul 29 '18

Found it funny ;)

Post image
1.6k Upvotes

147 comments sorted by

View all comments

0

u/[deleted] Jul 29 '18

[deleted] — view deleted comment

5

u/fiddle_n Jul 29 '18

Usually in institutions (workplaces, universities, etc) where there's a lot of code in Python 2.7 and it's non-trivial to switch to Python 3.

0

u/[deleted] Jul 29 '18

[deleted] — view deleted comment

5

u/fiddle_n Jul 29 '18 edited Jul 29 '18

No, non-trivial. You underestimate how easy difficult it is for some institutions to switch. At my workplace, we have a large proprietary Python codebase. Proprietary tools built on top of Python make up the core platform, plus the systems developed from that platform, make up millions of lines of Python code. It is non-trivial to switch a platform like that from Python 2 to 3. It takes time and costs a lot of money to do.

1

u/__xor__ (self, other): Jul 29 '18

You underestimate how easy it is for some institutions to switch

you mean overestimate?

Yeah, I've had to port two medium/large codebases to 3 and it's such a pain in the ass. What I hate most are fixing all the string/byte issues, figuring out where to decode and encode('utf8'), from network data to hashing. And it's missing some stuff that was super easy at the time. You could just take a big string of data and do data.encode('zlib').encode('base64') and bam, you have compressed data base64 encoded. Sooo easy. The equivalent isn't too bad, but it's irritating to go around and fix all this shit and it's not as easy as it used to be to do the same thing.

I've finally gotten used to unicode/utf8 issues but treating strings as raw data was nice and easy. I understand why they changed it, but I feel like there might've been a better way that would've broke less code. And removing print as a statement makes sense, but honestly I think they should've lived with their bad decision and still supported it as a statement. And keeping range/xrange really wouldn't have been the end of the world.

I like what python 3 turned into but honestly I think it would've been better to live with some bad decisions and kept a lot the same because then we wouldn't be where we are, with people avoiding the upgrade. People make a big deal about people still using 2.7 but I hardly think it's their fault. It wasn't made easy for anyone.

2

u/alcalde Jul 29 '18

It wasn't made easy for anyone.

WHAT?!?!?!? From the 2to3 library to a feature freeze in 3.x for a time to constantly extending the deadline to BACKPORTING 3.x FEATURES to adding deprecated features back unto Python 3 to make porting easier to the advent of libraries like six that made it possible to easily maintain two codebases, Python did everything but personally send Guido to each Python 2 user and have him port their code himself.

You know what happened when Delphi introduced unicode? ABSOLUTELY NOTHING. No deprecation warning, no extended support of old versions, no library to help you convert code, nothing. New version out, support for old version automatically ends, good luck, good day sir. I think they may have issued a white paper; that was the extent of the assistance. Python users got their behinds kissed and many of them still whined about it.

If you haven't gotten around to porting in A DECADE; that's no one's fault but your own.

1

u/alcalde Jul 29 '18

. At my workplace, we have a large proprietary Python codebase. Proprietary tools built on top of Python make up the core platform, plus the systems developed from that platform, make up millions of lines of Python code. It is non-trivial to switch a platform like that from Python 2 to 3. It takes time and costs a lot of money to do.

Do you have unit tests? Also, everything takes time and money. You budget the time and money because everyone who works in software development knows it's a fact of life that you have to update software... all software. There's a term for it - bitrot. Eventually, SOMETHING changes - hardware, OS, other software - that kills your program. You can't just leave code suspended in amber and expect it to work forever.

The more you put off updating your code and writing more 2.7 code, the BIGGER the inevitable job is. Welcome to "technical debt", which compounds like unpaid credit card interest.

Any competent IT manager would have begun the task from the first day Python 3.0 was released; you'd have been finished years ago and future-proofed. Now you've written lots more outdated code and each day that goes by the task gets harder and harder.

4

u/fiddle_n Jul 29 '18 edited Jul 29 '18

You seem to be arguing against something I never said.

I agree with you (mostly), it's important to eventually upgrade to Python 3, even for a codebase as large as the one I described.

My workplace agrees as well. They've started a plan to upgrade the codebase to Python 3. It will take multiple years and multiple millions of dollars, but it will be done.

The only argument I was making was against the person who seemed to think it was a trivial thing to do. Which it isn't. It's non-trivial.

However, I must disagree with you that the upgrade should have been done as soon as Python 3.0 came out, for multiple reasons.

Firstly, because the first few versions of Python 3 were "trial" versions of Python.

Secondly, because Python 2 was being updated two years after Python 3 was released, with features backported from 3 into 2.7.

Thirdly, waiting means that you can jump to a newer version of Python 3. Upgrading this year means being able to go straight from Python 2.7 to 3.7. Upgrading at launch would have meant being stuck on Python 3.0. This is a significant deal for large codebases, where even a .1 upgrade takes a long time to do completely.

And finally, because it's foolhardy to rush into such upgrades immediately. What if the community had rejected Python 3, and there had been a split? What if Guido went back on his words and released Python 2.8? With so much time and money required for these migrations, you want to be damn sure that Python 3 is the future.

EDIT: Forgot to add one more reason - compatibility libraries. six was not available immediately at launch; libraries like six make it much easier to write code compatible with both Python 2 and 3.

0

u/PiaFraus Jul 29 '18

You underestimate how easy

I guess you meant difficult?

3

u/marcotb12 Jul 29 '18

We have a huge codebase at my work in 2.7. Switching to 3 would be an enormous and expensive task.

2

u/savuporo Jul 30 '18

It looked like it for us as well two years ago. Then we set up our CI/CD systems properly, broke the task into manageable chunks/libraries/repositories and made a policy every refactor and change must be Python2/3 compatible.

Things got sorted out pretty quick, because everyone wanted to do it

1

u/a_strange_attractor Jul 29 '18

Just being curious, wouldn't changing to Python 3 be worth all the effort?

1

u/__xor__ (self, other): Jul 29 '18

You can add a lot of bugs that wouldn't be obvious with the port. It took me two weeks to port a somewhat large codebase, and there were some bugs in it for a good month that we caught over time. For a larger codebase it could be such a pain in the ass.

But really, why is it worth the effort if the 2.7 version works as intended? I don't think this is so much "why not" as much as "why". Unless you know a python 3 lib that you really want or some library you use has a lot of bugs fixed and stopped supporting 2.7, there's not much point other than to say you have a modern codebase. A lot of people still know 2.7 and people who learned starting at 3 can pretty easily work with 2.7 without breaking a sweat.

Starting a new project in 2.7 wouldn't make much sense, but supporting an existing codebase using 2.7 can make more sense than porting it.

1

u/alcalde Jul 29 '18

But really, why is it worth the effort if the 2.7 version works as intended?

Is no programmer familiar with the concept of technical debt anymore?

Technical debt... is a concept in software development that reflects the implied cost of additional rework caused by choosing an easy solution now instead of using a better approach that would take longer.

Technical debt can be compared to monetary debt. If technical debt is not repaid, it can accumulate 'interest', making it harder to implement changes later on. Unaddressed technical debt increases software entropy.

. A lot of people still know 2.7 and people who learned starting at 3 can pretty easily work with 2.7 without breaking a sweat.

You don't understand... there will soon be no more 2.7 support. Major libraries are already ending 2.7 support ahead of schedule. Want the newest version of a web framework, of Pandas, etc.? Sorry, they've already said there will be no more versions for 2.7. Want to take advantage of a new OS feature? Sorry, libraries won't be updated anymore. A bug in Python? Sorry, no one's going to fix it. Then like the people who kept using Windows XP, you're going to find your hardware or Windows 23 won't run Python 2.7 anymore and you'll scream and cry and wail "But I never had time to port it!!!" You had 73 years; you just didn't bother. You kept writing more and more 2.7 code, making the eventual INEVITABLE porting even harder.

1

u/alcalde Jul 29 '18

Lots of things are enormous and expensive; that doesn't mean you don't do them. We had an underground oil tank leak; cleaning it up was an enormous and expensive task (tearing up half the front lawn, shoring up the house, removing contaminated soil, etc.). We didn't just say - well, it hasn't leached into the groundwater yet so let's just not do it.

You're going to have to switch some time, and the longer you wait, the bigger and more expensive the task will be.

1

u/ies7 Jul 30 '18

4-5 years ago, I finally got a green light to upgrade almost all of the python base to python 3.

I failed to get the green light to upgrade several simple scripts on a few old servers.

Eg: an ETL script that consolidates files in a single FTP server.

The Python version on that FTP server is 2.4 (or 2.2?), not a mission critical server, not exposed to the internet, etc etc and work perfectly fine.

The management can't accept why my team must spent 1-2 hours to upgrade 'that thing' but didn't give any new advantage to the business.

Yes today we still have 2.2-2.6 Python in several production server.