2

I am still learning python and I started with Python 3. This question not Python 2 vs 3 or difference between them like print() is a function and not language construct and 3/2 = 1.5

My question is even if it is still python, what was the need of introduce something new which is not backward compatible, when -

  1. Syntax is the same
  2. Language philosophy is the same (import this)

Edit - Lets say all the popular packages are ported to Python 3, does that mean we no longer need Python 2

Mark Evans
  • 153
  • 6
  • 1
    The language designers decided that Python 2 had inadequacies in its design that couldn't be fixed without breaking some things, and figured it was more important to clean up the design than to be backwards compatible. It has a **Benevolent Dictator For Life** at the helm (_Guido van Rossum_), and he can choose to do pretty much anything he wants with the language. – KChaloux Dec 06 '13 at 13:32
  • @gnat we have Python 3 because it solves those problems that's it?? – Mark Evans Dec 06 '13 at 13:33
  • @KChaloux please also take a look at edit i have made – Mark Evans Dec 06 '13 at 13:34
  • 2
    Regarding the edit, almost _all_ languages have multiple versions. Older versions are frequently not completely compatible with newer versions. The old versions don't go away completely; they'll stick around in legacy applications. But new development is almost always done in the latest **stable** release of a programming language. – KChaloux Dec 06 '13 at 13:37
  • 1
    @MarkEvans "because it solves those problems that's it??" - yes, everyone would prefer backwards compatible improvements but when that's not possible you need to make backwards incompatible changes. – Simeon Visser Dec 06 '13 at 14:29
  • While the language philosophy is the same, but due to the natural growth, some parts of Python 2 is considered to not follow its own philosophy as closely as it could have, and they couldn't be fixed without backward incompatibilities or breaking the philosophy even further. Python 3 tries to clean up these warts, so the language follows the philosophy more closely. – Lie Ryan Jun 05 '16 at 16:31

2 Answers2

6

Python 3 was introduced to make improvements upon python 2, but I think what you are asking is why they are not backwards compatible. Basically, developers deliberately made python 3 not backwards compatible, for two main reasons:

  1. First of all, they wanted to change some things integral to python 2, and while the differences seemed small, the improvements that they had made would not have combined well with the existing structure. For example, the change to the "print" syntax you mentioned was made because print really is just calling a function, and really isn't a keyword in the same way that something like "if" or "while" is.

  2. The other reason backwards compatibility was severed was to keep python 2 and 3 separate. Some people, including me, prefer python 2.7 over python 3. Because python 3 made larger changes to the language, developers wanted to maintain the two versions almost as separate (if quite similar) languages.

For all intents and purposes, if you use python 2.7, the only difference that should really affect you is the change in "print".

trevorKirkby
  • 194
  • 1
  • 3
  • even java has evolved alot, but they never introduced two JREs – Mark Evans Dec 09 '13 at 15:05
  • 2
    okay I got that, every new development should happen in Python 3 and once we have ported to Python 3 we no longer need Python 2. [Hopefully one day everything will be greener.](http://python3wos.appspot.com/) – Mark Evans Dec 09 '13 at 15:14
4

In a talk I heard Guido say something like this:

You do not want your library in the Python standard library. Once it is there you can not change the API if you made any mistake.

So a reason I want to add is:

  • Incompatible changes to the API can only be made between Major Python versions.

Examples:

import SimpleHTTPServer
import CGIHTTPServer

changed to

import http.server
gnat
  • 21,442
  • 29
  • 112
  • 288
User
  • 795
  • 4
  • 9