How can we evaluate Python3's decision to break BackwardCompatibility?

Source: Internet
Author: User
Recently discussed in HackerNews: news. ycombinator. comitem? Id6985207news. ycombinator. comitem? Id7799524 from the comments, the comments of the community are very hierarchical. Some people think that the new features of Python3 are worthy of recognition. Some people also think that the new features brought by Python3 are insufficient to encourage programmers to migrate data and break backward compatibility, increase the discussion on recent Hacker News:
Https://news.ycombinator.com/item? Id = 6985207
Https://news.ycombinator.com/item? Id = 7799524

From the comments, the comments of the community are very divided into two levels. Some people think that the new features of Python 3 are worthy of recognition. Some people also think that the new features of Python 3 are insufficient to encourage programmers to migrate data. Breaking backward compatibility is even worse, this increases the cost of porting, and some dev simply switches to other languages, such as Go and Node. js.

So why does Python 3 decide to break backward compatibility from the beginning of design? Is it because developers are both good and evil, or do they have to make trade-offs for design and deep-seated reasons? In history, when other languages break backward compatibility, is the transition still stable? If so, how do they do it? Reply: The incompatible changes made by Python 3 have benefited a lot from this language. Here are two of the most obvious examples.
First, print is changed from statement to function. Look at this syntax:

print >> outfile, arg1, arg2
Opposed to anonymous users, Py3 is not a personal influence of developers ~~~ On the contrary, I think the upgrade of Py3 uses 「 NirvanaIt is not suitable.

It takes a long time to start from the beginning. I am not good at it either.

A long time ago, Python was just a scripting language and its position was similar to Perl, and even shell, awk, or sed. You can refer to the anti-quotation marks ''In py2 (like the anti-quotation marks in Perl ), and the construction of virtual machines (large loop, without JIT) can be a glimpse of one or two, In general, people think that "scripting language" is a "guerrilla", which is quite unusable.

Later, the Python community has been operating for many years and has gained a better position. In the areas of GUI development, Web development, and big data in recent years, at the beginning, there was some capital to compete with the traditional "Regular Army" Programming Language (compared to Java in various aspects). As a result, there were more and more people who wanted to "name" their ideas.

Python wants to develop towards regular armySeveral fundamental problems that plague its development need to be solved urgently, such as JIT, Sandbox, and GIL. In addition, we need to guard against the bad habits developed by the "guerrillas", which have the following problems:

Popen2 or even popen3 naming method. As to why popen2 cannot be named, Baidu "the worst two variable names in history 」
The print statement is incorrect. In "regular army", print cannot be a keyword, which is too low.
Threading. Thread, a module with different naming styles from other standard libraries, can be roughly referred to in PEP8.
Unicode problem. The problem of mixed use of str and byte must be learned from a good java student.
How can the regular army not even provide a decent sandbox (although py3 does not )~
......

Because there are too many problems to be solved, and some problems (such as JIT) are inevitable to "break the bones" (virtual machines and even bytecode need to be changed ), there are some problems that inevitably need to break down the downward compatibility (for example, the original code cannot run after the egg Module name is modified), and there are other things that make programming more convenient, such as unicode/byte, syntax form changes also break through downward compatibility.

Therefore, to have a better development, we must break it down from the past. Long pain is not as bad as short pain. So, let's start over. I have been reading the history of Python over the past two days-I wrote a blog on blogspot by the Python creator. I can tell you what I think. Answer the question first:
First, people will make mistakes, and their cognition will change with time. The development of programming languages is also necessary, so it is impossible to add languages (C ++ tries to develop in this way ). The author of Python has long thought that some things in Python are not correct, and some things are not well done. Why does Python 3 break backward compatibility? Nothing special. We just happened to catch up with this time. It wasn't just a flash of life. there was at least a few years of thinking behind this ......
I seem to have heard that there was an incompatible update in libc in the end of 1990s. At that time, all applications had to be re-edited to adapt to the new libc. I believe that at that time, the programmer's mind was also 10 thousand heads of mud galloping over ......
Then, breaking the backward transition to compatibility and stability is a conflict between the two things. I don't think anyone can do it. To do this, you just want people around the world to learn Korean after learning Korean. For programming languages, there is only one possibility of smooth transition to break compatibility: few people are using this language ......
How to evaluate this: this is a good thing, but it is not a big thing. It may bring us a little trouble, but 2.7 is still there. Which one do you like to use.
After learning about C ++, Erlang, Go, Java, Haskell, Scheme, Scala, Ruby, Python and other languages, I suddenly want to understand one thing: in fact, language is not important. Programming languages are useful, but not important. One sentence I saw two days ago: "It is a lesson which all history teaches the wise, to put trust in ideas and not in circumstance. ", I think it makes sense to choose a programming language: Don't trust (like) Those syntaxes, and keep confidence in the ideas behind them! Each language has a unique idea. The syntax for Python 2 to Python 3 has changed, but The Zen of Python hasn't changed, so I still have it!
I think The incompatibility between 2 and 3 is just The reaction of The Zen of Python in Python evolution. For example, The following several articles:
There shoshould be one -- and preferably only one -- obvious way to do it.
If the implementation is easy to explain, it may be a good idea. As a person, I am always honest and practical. 2.7, aiming at 3.x, it is estimated that this status may last for several years.
Do not mind writing something with 3.x, if you really don't need any dependencies.
There is still a way to be compatible, such as https://pypi.python.org/pypi/six
As for the practice of abandoning backward compatibility, it does not seem to have any impact on me (the reason is described above). This should be done, and it has improved a lot. Anyway, I am too weak to write things for a few years, why are there so many compatibility considerations? No one wants to find it! Incompatibility is a trade-off between future decisions. I think this decision is correct and can be established.

Sometimes it doesn't mean that you can be compatible If You Want To Be compatible. Unlimited compatibility means unlimited trouble.

For example, in windows, you cannot create a folder named COM1. Why? To maintain compatibility. You can check the information for specific historical reasons. Do you think maintaining such compatibility is good or bad for an ever-improving operating system?

To put it bluntly, there is a term in philosophy that is "discard". If you don't abandon the old things, you cannot fundamentally change and make progress.

Actually, we all know that we must include a version in the data when designing the protocol. In fact, if the language is the same ......


Fuck. py:

Import python2 // we can specify that python \ d + cannot be the name of a custom module.

Blahblahblah


Shit. py:

Import python3

Import fuck

Blahblahblah


It can then be mixed, but only one version can be used for one py, and files of earlier versions cannot see the symbols of later versions, which is easy and pleasant.

3 to 2, there is no essential performance improvement (including concurrency support), but there is essential syntax incompatibility, which is naturally undesirable. As far as I know, none of the widely used languages still have a smooth transition from backward compatibility.

If backward compatibility is lost, you are essentially a new language, so you naturally cannot fully enjoy and migrate the resources of the original language.

The original purpose of the C ++ language designer was to replace C. After so many years, he just became a language parallel to C, and there was no way to replace C. -- This means that no matter how beautiful a developer has, a widely used language is hard to be discarded out of thin air. If you stick to the incompatibility policy of python3, the consequence is that python3 and python2 develop into two different parallel development languages. There will always be a group that ignores python3

Lua is a typical version of incompatible versions. However, there is a problem here. Before Lua 5.1, Lua was not widely used. Lua's extensive application is actually in the Lua 5.1 age, which lasted for a long time.

Now Lua 5.2 is used, which breaks backward compatibility, but the vast majority of users still use the Lua 5.1 syntax. His migration to 5.2 may be a long process. LuaJIT, the brother project, announced that it would never support 5.2 in the foreseeable future and always adhere to the 5.1 syntax compatibility. This means that Lua 5.1 will continue to be the mainstream of Lua for a long time. And 5.2 became another language.

Although the C language has developed many standards over the years, it has not broken the backward compatibility. Very old code can still be compiled using today's Compiler (in extreme cases, some compiler options may be required ). This is a very typical example.

Python breaks backward compatibility, and of course it is purely a good and evil developer. What do you think? Let it go ...... In fact, you really don't have to think too much about it. The programs written on 2.5 in that year cannot run on 2.4. Adding a large version number makes some changes so normal. Compared to perl5 to perl6, python2to3 is as smooth as silk. The statement on the first floor is incorrect.
There is a language that breaks the compatibility in the evolution process, and the migration is not bad. It is Fortran.
The f90 Specification defines a number of "outdated features" (for example, the three-way if design for the old IBM machine). These features are deleted in f95, however, there is a "buffer" between f90 and f95, and this migration does not cause serious problems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.