3 ms·
For those you are still wondering why you should use Python 3, you should know that most of the reasons given to you have been far from the best one. The best
by sametmax 9y ago
For those you are still wondering why you should use Python 3, you should know that most of the reasons given to you have been far from the best one.
The best reason to move to Python 3 is:
-- It is just an easier language --
It's easier to write. It's easier to read. It's easier to maintain. It's easier to debug.
The problem is, there is no killer feature that shows that.
You only realize it when you wrote 10 projects in Python 2, and 10 in python 3, which I did.
What makes Python 3 easier is not "this one big thing", but a hundred of little things that cumulatively make your whole program just easier to <anything>.
Among the stuff:
- A lot of mistakes you could make with Python 2 are impossible in Python 3. Stupid comparisons, bad import layouts, concatenation of string and bytes, overriding keywords, loading too many objects in memory...
- Things are just less verbose. Automatic super(), no object inheritance, better unpacking, no from __future__ or encoding declaration, no longer generator aliases, f-strings, imports from codec...
- The right thing to do is more obvious. Way less aliases for modules, methods and built-ins, the easiest way is usually the best way (f-strings, range(), etc), division is doing what people thinks...
- The stdlib is way more consistent. Better naming, unicode/bytes in => unicode/bytes out, the __path__ protocol allow Path objects everywhere...
- Python is globally easier to debug. The error messages are better, we have new tools to debug memory consumption, but all in all, because everything is easier, you just produce less bugs. And you can type check on big code bases if you wish to.
Each of those things are not revolutionary. But cumulatively they are adding up to a huge difference. Much like being in the sea doesn't feel that much different until you go out and gravity calls again. That's why it has been hard to sell.
That and the fact Python 3 has started to be usable only on 3.3, cool in 3.5 and to really, really rock in 3.6.
What's more, most of those things could NOT have been done without breaking compatibility. True, improving error messages could, but fixing unicode, comparison, verbosity, naming, etc. would have broke so many programs anyway. But yes, they could have been done more incrementally though.
However, I can't help but notice that a lot of people complaining are doing so for the sake of it. Without real knowledge about it.
Most porting take a few minutes to a few hours. Not kidding. I've been doing that a lot. It's way scarier in people's head.
In reality, it is not that much work. Very few people have such a big and complicated code base that it's hard to port. They do exist. And it's a real pain for them. But most people on this thread are not them.
Porting to Python 3 is most of the time really easy, and the gain , while not obvious at first, are actually quite enormous.
What's hard is to make this shitty mix of 2 + 3 compatible code base.
In all case, I'm quite glad a lot of people will wait until the last minute to migrate. I'm starting to position myself as a consultant export in 2 => 3 and I plan to make a lot of money with it in 2020.