Home  >  Article  >  Backend Development  >  An introduction to the development of the Python programming language

An introduction to the development of the Python programming language

高洛峰
高洛峰Original
2017-03-23 15:58:531364browse

Python is my favorite language. It is simple, beautiful and easy to use. Two days ago, I was very excited Promote the benefits of Python to friends

"Okay, I admit that Python is good, but why is it called Python? "
"Well, it seems to be the name of a TV series. "
"Then is the Guido you are talking about American? "
"He moved from Google to Dropbox, but his name sounds like a Dutch one. "
"Are you sure you are familiar with Python? ”

So in order to avenge my shame, I took the time to investigate the history of Python. I saw the origin of many functions in Python and the design philosophy of Python, and saw a programming language The evolutionary history of Python and the wonderful connection between Python and the open source movement. From the history of Python, we can get a glimpse of the concepts and achievements of open source development.

This can also be used as a preface to the Python quick tutorial I wrote. .

Origin

The author of Python, Guido von Rossum, is indeed Dutch. In 1982, Guido received a master's degree in mathematics and computer science from the University of Amsterdam. Mathematician, but he enjoys the fun of computers more. In his words, despite having dual qualifications in mathematics and computers, he always tends to do computer-related work and is keen on doing anything related to programming

At that time, Guido came into contact with and used languages ​​such as Pascal, C, and Fortran. The basic design principles of these languages were to make machines run faster. Apple has set off a wave of personal computers, but the configuration of these personal computers is very low. For example, the early Macintosh only has an 8MHz CPU frequency and 128KB of RAM. A large array can fill up the memory. Optimize so that the program can run. In order to improve efficiency, the language also forces programmers to think like a computer so that they can write programs that are more in line with the taste of the machine. In that era, programmers could not wait to squeeze it by hand. The power of every inch of the computer. Some people even think that the pointers of C language are a waste of memory. As for dynamic types, automatic memory management, object-oriented... Don't think about it, that will make you. The computer is paralyzed.

This kind of programming makes Guido feel distressed. Guido knows how to write a function in C language, but the whole writing process takes a lot of time, even if he already knows exactly how to implement it. His other choice is the shell. Bourne Shell has been around for a long time as an interpreter for UNIX systems. UNIX administrators often use the shell to write some simple scripts, such as regular backups and File systemManagement, etc. The shell can be like glue to connect many functions under UNIX. Many programs with hundreds of lines in the C language can be completed in only a few lines. The essence is to call commands. It is not a real language. For example, the shell does not have numerical data types, and the addition operations are very complicated. In short, the shell cannot fully mobilize the functions of the computer. #Guido hopes to have a language that can fully call the functional interface of the computer like C language, and can be programmed easily like shell. ABC language gives Guido hope. ABC was developed by the Institute of Mathematics and Computing in the Netherlands. Guido worked at the institute and was involved in the development of the ABC language. ABC language is for teaching purposes. Unlike most languages ​​at the time, the goal of the ABC language was to "make users feel better." ABC Language hopes to make the language easy to read, easy to use, easy to remember, and easy to learn, and to stimulate people's interest in learning programming. For example, the following is an ABC program from Wikipedia, which is used to count the total number of words appearing in a text:

HOW TO
RETURN

words document: PUT {} IN collectionFOR line IN document:
FOR word IN split line:

IF
word not.in collection:INSERT word IN collectionRETURN collection

HOW TO is used to
define a function

. A Python programmer should easily understand this program. ABC language uses colons and indentation to represent blocks of programs. There is no semicolon at the end of the line. There are also no parentheses () in the for and if structures. Assignment uses PUT instead of the more common equal sign. These changes make the ABC program read like a text.

Despite its good readability and ease of use, the ABC language ultimately did not become popular. At that time, the ABC language compiler required a relatively high-end computer to run. The users of these computers are usually computer proficient, and they consider the efficiency of the program more than the difficulty of learning it. In addition to hardware difficulties, the design of the ABC language also has some fatal problems:

Poor scalability. ABC language is not a modular language. If you want to add functions to the ABC language, such as graphical support, you must change many places.

Cannot perform IO directly. ABC language cannot directly operate the file system. Although you can import data through methods such as text streams, ABC cannot read and write files directly. The difficulty of input and output is fatal to computer languages. Can you imagine a sports car with doors that can't be opened?

Over-innovation. ABC uses natural language to express the meaning of the program, such as HOW TO in the above program. However, for programmers, they are more accustomed to using function or define to define a function. Likewise, programmers are more accustomed to assigning variables using the equal sign. Although the ABC language is very special, it is also very difficult to learn.

Difficulty in spreading. The ABC compiler is large and must be saved on tape. When Guido visited, he had to have a large tape to install the ABC compiler for others. In this way, it is difficult for ABC language to spread quickly. In 1989, in order to pass the Christmas vacation, Guido began to write a compiler for the Python language. The name Python comes from Guido’s beloved TV series Monty Python’s Flying Circus. He hopes that this new language called Python can meet his ideal: to create a language between C and shell that is comprehensive, easy to learn, easy to use, and scalable. As a language design enthusiast, Guido has already tried to design languages. This time, it was just a pure hacking

behavior

. The birth of a language

In 1991, the first Python compiler was born. It is implemented in C language and can call C language library files. Since its birth, Python has had: classes, functions,

Exception handling

, core data types including tables and dictionaries, and a module-based expansion system. Python syntax comes from C, but is strongly influenced by the ABC language. Some rules from the ABC language are controversial to this day, such as forced indentation. But these syntax rules make Python easy to read. On the other hand, Python smartly chooses to obey some conventions, especially those of the C language, such as regressing the equal sign assignment. Guido believes that if something is established based on "common sense", there is no need to get too hung up on it.

Python has paid special attention to scalability from the beginning. Python can be extended on multiple levels. At a high level, you can import .py files directly. Under the hood, you can reference C libraries. Python programmers can quickly use Python to write .py files as expansion modules. But when performance is an important factor to consider, Python programmers can go deep into the bottom layer, write C programs, compile them into .so files and introduce them into Python for use. Python is like building a house with steel. First define a big

frame

. Programmers can expand or change quite freely under this framework. The original Python was developed entirely by Guido himself. Python is popular among Guido's colleagues. They provide quick feedback and participate in Python improvements. Guido and some colleagues form the core team of Python. They spend most of their spare time hacking Python. Subsequently, Python expanded beyond the institute. Python hides many machine-level details and leaves them to the compiler to handle, and highlights logical-level programming thinking. Python programmers can spend more time thinking about the logic of the program instead of specific implementation details. This feature attracts a large number of programmers. Python became popular.

An introduction to the development of the Python programming languageLife is short, I use python

The times create heroes

We have to pause our Python time and look at a Look at the rapidly changing computer industry. In the early 1990s, personal computers began to enter ordinary households. Intel released the 486 processor, and Windows released a series of window systems starting with window 3.0. Computer performance is greatly improved. Programmers began to pay attention to the ease of use of computers, such as graphical interfaces.

An introduction to the development of the Python programming languageWindows 3.0

As computer performance improves, the world of software begins to change. The hardware is sufficient for many personal computers. Hardware manufacturers are even eager for the emergence of high-demand software to drive upgrading of hardware. C++ and Java became popular one after another. C++ and Java provide object-oriented programming paradigms and rich object libraries. At the expense of a certain amount of performance, C++ and Java have greatly improved program output. The ease of use of the language has been taken to a new level. We also remember that an important reason for the failure of ABC was the performance limitations of the hardware. In this respect, Python is much luckier than ABC.

Another change that is happening quietly is the Internet. The 1990s was still the era of personal computers. Windows and Intel dominated the world with PCs and became very popular. Although the Internet-based information revolution has not yet arrived, many programmers and experienced computer users are already frequently using the Internet to communicate, such as using email and newsgroup. The Internet has greatly reduced the cost of information exchange. A new software development paradigm is beginning to gain popularity: open source. Programmers use their spare time to develop software and open source code. In 1991, Linus released the Linux kernel source code on the comp.os.minix news group, attracting a large number of hackers to join. Linux and GNU work together to form a vibrant open source platform.

Hardware performance is not a bottleneck, and Python is easy to use, so many people are turning to Python. Guido maintains a maillist, and Python users communicate through email. Python users come from many fields, have different backgrounds, and have different needs for Python. Python is quite open and easy to expand, so when users are not satisfied with the existing functions, it is easy to expand or transform Python. These users then send their changes to Guido, who decides whether to add the new features to Python or the standard library. It would be a great honor if the code could be incorporated into Python itself or the standard library. Because of Guido's supreme decision-making power, he is known as the "Lifelong Benevolent Dictator."

Python is called "Battery Included", which means that it and its standard library are powerful. These are contributions from the entire community. Python developers come from different fields, and they bring the advantages of different fields to Python. For example, the regular expressions in the Python standard library refer to Perl, while functions such as lambda, map, filter, and reduce refer to Lisp. Some features of Python itself and most of the standard library come from the community. The Python community continues to expand and has its own newsgroup, website, and fund. Starting from Python 2.0, Python has also changed from a maillist development method to a completely open source development method. A community atmosphere has been formed, work is shared by the entire community, and Python has also achieved faster development.

Today, the framework of Python has been established. The Python language organizes code with objects as the core, supports multiple programming paradigms, uses dynamic types, and automatically recycles memory. Python supports interpreted execution and can call C libraries for expansion. Python has a powerful standard library. Since the standard library system has stabilized, the Python ecosystem has begun to expand to third-party packages. These packages, such as Django, web.py, wxpython, numpy, matplotlib, and PIL, upgrade Python into a species-rich tropical rainforest.

Revelation

Python advocates elegance, clarity, and simplicity, and is an excellent and widely used language. Python ranks eighth in the TIOBE rankings. It is Google's third largest development language, Dropbox's basic language, and Douban's server language. The development history of Python can be used as a representative and brings me a lot of inspiration.

In the development process of Python, the community plays an important role. Guido thinks that he is not an all-round programmer, so he is only responsible for formulating the framework. If the problem is too complicated, he will choose to go around it, that is, cut the corner. These problems are ultimately solved by others in the community. The talents in the community are extremely rich. Even things that are slightly distant from development, such as creating websites and raising funds, there are people who are willing to handle them. Today's project development is becoming more and more complex and larger. Cooperation and an open mind have become the keys to the ultimate success of the project.

Python has learned a lot from other languages, whether it is ABC that has entered history, or C and Perl that are still in use, and many other languages ​​​​not listed. It can be said that Python's success represents the success of all the languages ​​it draws from. Similarly, Ruby borrows from Python, and its success also represents the success of Python in some aspects. Every language is a hybrid, with its strengths and weaknesses. At the same time, the judgment of "good or bad" of a language is often subject to external factors such as platform, hardware, era, etc. Programmers experience many language battles. In fact, if you accept various languages ​​with an open mind, maybe one day programmers can mix their own languages ​​like Guido.

No matter what the future fate of Python is, the history of Python is already a very interesting novel

The above is the detailed content of An introduction to the development of the Python programming language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn