DEV Community

Cover image for Python 2 VS Python 3
Kostas Sar
Kostas Sar

Posted on

Python 2 VS Python 3

This time we visit the topic "Should I use Python 3 as it is the latest version or should I stick to Python 2 because most of the internet says so?"

Disclaimer: I am quite Python 3 sided and looking for more of its drawbacks, so feel free to disagree with anything.

Key Differences from Python 2 to Python 3

  • Syntactical, best shown by the print function.
  • Division with integers now outputs decimals if needed
  • Unicode as default character encoding

And with the technical stuff out of the way, let's see what divides the community.

Libraries

The main pro Python 2 argument is that every library ever is written for it and if one switches to Python 3 won't be able to find and use any of them. I believe this argument is quite outdated as Python 3 is now 10 years old and many libraries are now updated and functional. Some teams even start a project and in case the needed library is missing they code it, document and upload it. Very kind of them, isn't it?
Right now the only libs you can't find are the really obscure and unpopular ones. But if you are lucky one of the teams mentioned above will stumble on them and make it available to the rest of us!

Dev Support

Python 2.7 is no longer under development and in 2020 will even be discontinued. In contrary Python 3 will have new features, active support and stable releases.

Reasons to stick with Python 2

The only reason I thought was not outdated about sticking with Python 2 is the following.
One might be in a large company and all the code is written in Py2. Refactoring to Py3 will not only halt the development but also cost money as the engineers tampering with the code must get paid.

As quoted by the Python team:
"Python 2.x is legacy, Python 3.x is the present and future of the language."

What is your opinion on the matter?

Top comments (17)

Collapse
 
rhymes profile image
rhymes

It's a little harsh, don't you think?

Usually the transition is slow because it costs time and money to do it, especially in apps with a lot of legacy code or with a high demand of features by existing clients.

Regarding Apple I'm not sure what you're referring to. Do they use Python for anything?

 
rhymes profile image
rhymes

I do not think it's productive to bash on an entire community just because you don't like the syntax or do not find worth in the language.

Python is definitely not perfect but as you said, Python 3 is better than Python 2. If it were true that Python was worse of every other language you mentioned people wouldn't be using it. The truth, like with everything, is that it depends on many aspects like for example: need. Julia is faster than R but it's not more popular in that niche. For example.

I have been programming with Python for a long time and I don't remember codebases with people going crazy with operator overloading. Sometimes things get really complicated when meta classes are involved, I give you that.

I'm sure the people at Apple aren't unaware of the end of life date of Python 2, if as you say it's used by internals they might be planning on replacing it in the next few versions of macOS

BTW try avoiding using built-in languages in general. I always try to avoid messing with the built-ins of the operating system, be it Python or any other language.

 
rhymes profile image
rhymes • Edited

Rob, let's be honest, your definition of objective is not objective. It's really really hard to create an objective analysis of everything, let alone something that riles you up this much. Let's start from your comments:

NO ONE should learn Python 2! If you do, you are either completely uninformed or an total moron not worthy of gainful employment as a programmer anywhere in the universe. 😁

Installing Python continues to remain a nightmare similar to managing Java JREs

Python will eventually become one of the most hyped, popular dead languages. It does nothing particularly well.

To me the only languages anyone ever really needs to learn are HTML, CSS, JavaScript, Go, Shell, C

The only thing Python is good at is convincing beginning programmers that code can be forced to look like English language pseudo-code until later when they encounter the obfuscated Python of programmers who think they are being clever

Please, tell me which of these is an objective analysis of anything. You're subtly (not subtly enough because even not a master of the English language like I am can detect the nuance) saying "Python is crap, please don't bother, use this instead". It's your right to say it, but please don't hide behind the word "objective". It's the oldest trick in the game and I've been that guy in the past. I know about this because I have been a programmer convinced my way was the right way and the others were wrong in a previous lifetime. I bashed PHP in the past for similar reasons. PHP is still here.

Even if Python were indeed to become a dead language (which it absolutely can in the grand scheme of things) this still doesn't render your argument objective.

I agree 100% with you when you say to not use popularity as a metric but popularity is important nonetheless because not everyone is in this business to become a master, people can go far being programmers using a popular tool learnt because the company they wanted to work for uses it. There's nothing wrong with that.

Don't be that guy at the entrance of the Star Wars convention shouting "Star Trek is better" :-D

Collapse
 
shaiay profile image
shaiay

The problem I see with upgrading to python 3, apart from the cost of converting a large codebase, is, which python 3?
Every minor version of python 3 introduces new language features which are not backward compatible. How do you manage your codebase with such a constantly changing language?

Collapse
 
obiwac profile image
Obiwac

I fully agree with you. I don't use python much (except for small, random stuff, like a discord bot) but when i do (and i have to use a library that only supports 3.6), i always get confused as to how things are done differently in the current iteration than the one before it.

I guess my biggest gripe with python3 is that it's not backwards compatible with python2 (and, as you said, with 3 itself sometimes) with all that Unicode bullshit and the way they changed print. I do understand (and agree) that in the long term these are better solutions, but we are not living in the future, and this is confusing. At least give us the option to choose between the old ASCII strings and the new Unicode ones. This would also help so much in porting old libs to 3 (not that it would be a good idea that way, but at least id have access to all the libs i had in 2).

 
rhymes profile image
rhymes

From Merriam Webster - merriam-webster.com/dictionary/obj...

expressing or dealing with facts or conditions as perceived without distortion by personal feelings, prejudices, or interpretations

I haven't find a single history book that's objective. You're going to do way better than famous historians to convince me your argument is 100% objective.

You mention a statement on Python 3 as a shield for your argument but I still don't know what are you referring to. Also you're mixing arguments against Python as a whole and Python 2.

So ignoring a statement I can't argue with because I don't know what it is and Python 2 lack of Unicode support which is false because Python 2 has it (definitely not the best support ever, but it's there which invalidates your third point).

The only thing that I have to take home about your "objective" argumentation is that "Python sucks because lambda functions cannot be multi-line". So your entire evaluation of a language is based on a single feature that can be easily avoided with inline functions? Good to know :-)

Also please stop calling people morons because they use something you think they shouldn't.

By the way nobody in this thread, not even the original poster, it's arguing to pick up Python 2. We only said that you might be using it in present day because of legacy code, which is also what came up in the threads of comments when I posted to start a discussion about people stuck with Python 2.

 
rhymes profile image
rhymes • Edited

It's really hard for me to have a meaningful discussion because you mix outrageous things like "Python is bad for your brain" with understandable things like "We need languages with concurrency builtin" :-)

Also you say stuff that contradicts statements you made five minutes before. You say "functional paradigms work better on concurrent computing" but then you just finished arguing that the best things are Go and C, neither of them is strictly functional and they are as functional as any general purpose language: you can write code "functional style" instead of using OOP for everything. Which you can do in Python as well by the way, nobody forbids it.

I agree that there are better languages than (C)Python 3 for writing massively concurrent applications, but from there to saying "it's bad for your brain" is a looooong stretch I'm not willing to follow you on, I'm sorry.

Going around calling people morons isn't productive at all especially because you equate your personal experience or preference with "fact" which to me amounts only to perceived arrogance, not objectivity.

Defending your opinion using technology masters that might have been verbally abusive (and some still are) is also not the best way to advance your argument. Read the room ;-)

Collapse
 
rinzler profile image
Rinzler

As a python beginner back in 2016, I had the same doubt, then I read this on the docs:

  • "Python 2.7 is no longer under development and in 2020 will even be discontinued."

No one wants to build an entire codebase which will be legacy within 4 years.

Collapse
 
kostassar profile image
Kostas Sar

Exactly! Now it's even scarier with 1.5 year remaining.

 
rhymes profile image
rhymes • Edited

I never said, "purely functional" only that the language is functional friendly, which Python very objectively is not (absence of anonymous functions being the first indicator).

So what do you call closures, lambdas, a builtin map function, list comprehensions, callables, higher order functions and lazy evaluation if not functional constructs?

I'm sure you will reply saying "hey, you can't write multi line anonymous functions so everything else you just said it's moot" :-)

(And yes that is an opinion, which is shared by Stanford and Carnegie Mellon.)

Please, link me something where they say that OOP is bad for your brain (and no, not something where someone says FP might be a better intro to programming). Words have meaning. You know you can do OOP in C right? So C is bad for your brain because it supports OOP?

Defaulting to for loops, for example, instead of thinking of how such interaction would happen concurrently through, say, a map/reduce/filter approach is definitely going to cause you to write non-concurrent code

Not all code has to be concurrent. Not all programs are massively parallel. I'm sure there's no point in me telling you that you can do parallel, map reduce in Python also. I have had a feeling since your first post that you decided that you're right despite any argument that might chip at the argument :-)

I read your post by the way and I agree with part of it and disagree with other parts but after your very elegant closing up here I don't think I have the will to keep on arguing.

Let's agree to disagree and call it a day.

Collapse
 
itr13 profile image
Mikael Klages

Python can be good to know for smaller projects, or when you need to write a quick cross-platform script, but one should never learn it as one's only language (unless you do a minimal amount of programming, I guess).

Though on the topic of first languages, is javascript that good of a first language? Wouldn't it be better with a language with slightly more static testing and less random pitfalls to fall into?

I was thinking of teaching a kid of a colleague how to program (they're familiar with scratch, though I don't know how much), but I'm not sure which language to start with. I was thinking of starting with lua very briefly to show how the graphical language converts to the text-based one, then move over to another language, but I have a feeling that's a terrible idea, lol

 
itr13 profile image
Mikael Klages

Scratch is certainly surprisingly powerful, I remember a few years back I was browsing on r/proceduralgeneration, and saw somebody had made a randomly generated terrain with a car that moved on it with bounce-physics (though the car always had the same x position)

I've never looked into spigot before, seems interesting, though maybe it works better when there are multiple people being taught?

For javascript, do you usually go the more text in/out route or directly at graphics? Do you use a framework/engine like node.js?