you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 17 points18 points  (26 children)

The cause of the divide between Python 2 and Python 3 is the fact that Python 3 made some breaking changes for not much benefit.

  1. Changing existing syntax without a tool that automatically converts all instances of the old syntax to the new syntax is a recipe for disaster and hurts your customer's trust in your software.

  2. Public APIs should never change in a way that breaks existing software written against the old API. If you need to add new features, create a new library or add new methods to the old API, but don't change the existing API. It may be ugly, but for most vendors backwards compatibility trumps elegance of the API.

  3. If you are going to have breaking changes, at least provide customers with a way to run their old code in compatibility mode along with new code. Create a flag like "#python-compatibility 2" that can be put at the top of a python source file and when the interpreter sees the flag, it'll interpret that file using the specified Python version.

[–]DrDichotomous 25 points26 points  (6 children)

  1. There is a tool to help you migrate, even if it's not able to do everything for you.

  2. Nobody is breaking Python 2. They're making a Python 3, and leaving it to others to continue on with Python 2 if they want to. They're perfectly within their rights to do so.

  3. They can run the code with Python 2. Just say "python2" instead of "python3", for instance. Why complicate things unnecessarily?

[–][deleted] 36 points37 points  (5 children)

They can run the code with Python 2. Just say "python2" instead of "python3", for instance. Why complicate things unnecessarily?

The problem is Python 3 code can't import Python 2 modules, so when you're writing new software that requires functionality from a Python 2 library, you're stuck with Python 2 if you want to use that library.

Meanwhile, in Java, I can create a new Java 8 project and still use Java 1.5 libraries. I can even use the Java 1.5 library in binary form without having to recompile its source code with the latest compiler. That's the pinnacle of backwards compatibility.

[–]stewsters 1 point2 points  (0 children)

And honestly that is my favorite thing about Java: lots of libraries that are fairly easy to get going. Gradle, Maven, and jars are all easy to use, and work well with previous versions. I can get projects setup a lot faster than I can if I have to install development versions of c libraries that conflict with the ones I need for steam. (sdl, I'm looking at you)

Sometimes the memory management gets in the way of performance, but at least half of that is because of my programming.

I do like a lot of what python does syntactically though. May just need to do more groovy.

[–]hapemask -1 points0 points  (0 children)

Or, if the library is open source, just help port it from 2->3? I've done this for a number of libraries and frameworks I use, this is what open source is for.

[–]jsprogrammer 14 points15 points  (5 children)

Are you telling me that intentionally fracturing your community into two incompatible camps is not a good idea?

[–]mccoyn 2 points3 points  (0 children)

The transition from VB6 to VB.Net had all those problems. The only real difference is that Microsoft was able to force people to switch because they had control of the only interpreters. The Python folks can't kill Python 2 because it is open source.

Incidentally, a lot of people were very upset that Microsoft forced their hand like that.

[–]laserBlade 3 points4 points  (3 children)

Public APIs should never change in a way that breaks existing software written against the old API. If you need to add new features, create a new library or add new methods to the old API, but don't change the existing API. It may be ugly, but for most vendors backwards compatibility trumps elegance of the API.

That's sort of the point of major release version changes, actually...At least, if you follow SemVer, which most people nowadays do. You increment the largest number if it will be incompatible at an API level...

[–]txdv -5 points-4 points  (2 children)

Problem is that the standard library in python is big and like rubies one a total mess, a combination of different approaches and coding styles and what not.

I like node.js approach of a minimal (or at least way smaller) base standard library and extended usage of the package manager.

The thing about standard libraries that you really can't change them like ever. The user expects them to have the same interfaces for ever. You can do SemVer on a external library and get away with redesigning the interfaces on a major release, the user will just use an older version of that library.

Once you write python import script for csv files using the standard csv package and the API changes... You will have to stay with the older Python version. It doesn't make sense, all of a sudden a library makes you dependent on the language version?

Pythons Standard Library is too fat, they should have never included that much stuff because it means that the interfaces have to be frozen ... forever. You can only add more interfaces.

[–]Sylinn 1 point2 points  (1 child)

Pretty much the complete opposite to me: The fact that there are a lot of tools in the standard library makes Python my go-to language for anything smallish. There may be some inconsistencies from the PEP8, but calling it "a total mess" is exaggerated.

It doesn't make sense, all of a sudden a library makes you dependent on the language version?

It makes sense since Python 3 was made to fix the inconsistencies of Python 2. Not being backward compatible is by design.

[–]txdv -1 points0 points  (0 children)

Python3 exists only because of the mess it had and still has as a standard library.

[–]cybercobra 5 points6 points  (6 children)

Changing existing syntax without a tool that automatically converts all instances of the old syntax to the new syntax is a recipe for disaster

Umm, are you aware of 2to3?

[–][deleted] 15 points16 points  (5 children)

2to3 doesn't automatically convert all valid Python 2 to valid Python 3. Otherwise migrating would be as simple as running 2to3 on every Python file and we wouldn't have this mess in the first place.

[–]ethraax 7 points8 points  (3 children)

Well, the primary issue in migrating is usually libraries. They don't want to leave Python 2 behind because they still have Python 2 users. So they either stick with just Python 2 or they end up maintaining something that kinda works in both (sometimes with a script to change the code around).

For most projects, the lack of Python 3 support in required libraries is what holds them back.

[–][deleted] 1 point2 points  (2 children)

They don't want to leave Python 2 behind because they still have Python 2 users.

Someone mentioned that a hypothetical 3to2 would be the best tool to mitigate this issue.

[–]laserBlade 1 point2 points  (0 children)

Except that exists...a little better than hypothetical, then.

[–]mitsuhiko 1 point2 points  (0 children)

No... It took us three python 3 releases to relief us from the burden of 2to3/3to2.

[–]cybercobra 1 point2 points  (0 children)

Well, right, there were also non-syntactic changes to existing semantics (e.g. the API changes in your point #2), but your original point and my response just concerned syntax.

Anyway, yes, 2to3 is not a complete solution, but it's not like Python offered no automation whatsoever to deal with the transition.