Home >Backend Development >Python Tutorial >What type of programming language is python?
Python is an object-oriented dynamic and strongly typed programming language. It is an organized and powerful object-oriented programming language. Python is simple and easy to use, has low learning cost, and looks very elegant and clean; Python has many standard libraries and third libraries and is powerful, and can develop both small tools and enterprise-level applications.
The operating environment of this tutorial: windows7 system, python3 version, DELL G3 computer
What is the language of python
Python is a methodical and powerful object-oriented programming language. It is a dynamic, object-oriented, strongly typed scripting language (interpreted language). The author is the Dutch Guido van Rossum (Guido van Rossum, Chinese programmers call him "Uncle Turtle").
Strong type: Do not allow addition of different types
Dynamic type: Do not use explicit data type declaration, and determine the type of a variable is When assigning a value to it for the first time
Script language: It is generally an interpreted language. At the moment before the program is run, there is only the source program and no executable program; and every time the program executes a certain instruction of the source program, the interpreter converts the source code into binary code for execution; in short, it is continuous interpretation and execution , explanation, execution...
The birth of Python is very dramatic. According to Guido's self-report, the Python language was developed during the Christmas period to kill boring time. The reason why Python was chosen as the name of the programming language was because Guido was a big fan of the Monty Python theater troupe.
Picture: The father of Python - Guido van Rossum
The Python language was developed on the basis of the ABC language, and its original design was Become a replacement for ABC language. Although the ABC language is a powerful high-level language, unfortunately, due to the fact that the ABC language is not open, it has not been widely used. Based on this consideration, Guido decided to open source Python when he first developed it.
Python not only adds many functions that the ABC language does not have, but also designs a variety of rich and powerful libraries for it. Using these Python libraries, programmers can use various modules produced in other languages. (especially C language and C) can be easily "glued" together, so Python is often called the "glue" language.
Note: The libraries and modules mentioned here are simply understood as source files. Each file contains methods (also called functions) that can implement various functions.
On the whole, the biggest feature of the Python language is simplicity, which is mainly reflected in the following two aspects:
Python’s syntax is very concise and clear, even if it is not It is also easy for beginners who are software majors to get started.
Compared with other programming languages, the implementation code of Python language is often the shortest to implement the same function.
Why Python is popular
Python is an open source interpreted scripting programming language. The reason why it is very popular , mainly for three reasons:
Python is simple and easy to use, has low learning cost, and looks very elegant and clean;
Python standard library and There are many three libraries with powerful functions. It can develop both small tools and enterprise-level applications;
Python stands at the forefront of artificial intelligence and big data. Standing at the forefront, Pigs can fly.
Let’s take a simple example to illustrate the simplicity of Python:
For example, to implement a certain function, C language may require 100 lines of code, while Python may only require A few lines of code, because everything in C language has to be started from scratch, and Python already has many common functions built in. We only need to import the package and then call a function.
Simplicity is one of the great charms of Python and its trump card. Once you are used to Python, it is simply unbearable to use C language again.
Advantages of Python
1) Simple syntax
And traditional C/C, Compared with languages such as Java and C#, Python has less stringent requirements for code format. This looseness makes users more comfortable when writing code without spending too much energy on minutiae. Let me give you two typical examples:
Python does not require a semicolon at the end of each statement, of course it is correct;
You do not need to specify the type when defining a variable, even Different types of data can be assigned to the same variable.
The above two points are also features of common scripting languages such as PHP, JavaScript, and MATLAB.
Python is a programming language that represents minimalism. Reading a piece of beautifully formatted Python code is like reading an English paragraph, which is very close to human language. Therefore, people often say that Python is a kind of pseudo-programming language. Code features of programming languages.
Pseudo Code (Pseudo Code) is an algorithm description language, which is between natural language and programming language. The purpose of writing pseudocode is to make the described algorithm easier to implement in any programming language, such as C, C, Java, etc. Therefore, pseudocode must be clearly structured, simple, readable, and similar to natural language. If you have studied data structures and read Yan Weimin's books, then you must know what pseudocode is.
Why is simplicity the trump card? Once it is simple, a thing becomes pure; when we develop Python programs, we can focus on solving the problem itself without worrying about the minutiae of syntax. Doing something pure in a simple environment is simply a pleasure.
2) Python is open source
Open source, that is, open source code, means that all users can see the source code.
Python’s open source is reflected in two aspects:
① The code written by programmers using Python is open source.
For example, we develop a BBS system (i.e. online forum) and put it on the Internet for users to download. Then what the users download is all the source code of the system, and they can modify it at will. This is also a characteristic of interpreted languages. If you want to run a program, you must have source code.
② The Python interpreter and modules are open source.
The official source of the Python interpreter and module code is to hope that all Python users will participate in improving Python's performance and making up for Python's loopholes. The more the code is studied, the more robust it will be.
There is always a small group of people in this world who either do not seek fame or wealth, or they will continue to strengthen and improve Python in order to achieve a certain purpose. Don't think that everyone is only interested in immediate interests. There are always some elites who will take the long term to catch big fish, and there are always some geeks who will do some cool things.
3) Python is free
Open source does not mean free. Open source software and free software are two different concepts, but most open source software is also free software. ; Python is such a language that is both open source and free.
If you want to distinguish the concepts of open source and free, please hit: Does open source mean free? Speak with facts
Users use Python to develop or publish their own programs without paying any fees or worrying about copyright issues. Even for commercial use, Python is free.
4) Python is a high-level language
The high-level mentioned here means that Python has a deeper encapsulation and shields many underlying details. For example, Python will automatically manage memory ( Automatically allocated when needed and automatically released when not needed).
The advantage of high-level language is that it is easy to use, and you don’t have to worry about the details; the disadvantage is that it is easy for people to get a taste of it and not know why.
5) Python is an interpreted language and can be cross-platform
Interpreted languages are generally cross-platform (good portability), and Python is no exception. We have already explained it in "The Difference between Compiled Languages and Interpreted Languages" and will not go into details here.
6) Python is an object-oriented programming language
Object-oriented (Object Oriented) is what most "modern" languages (i.e., third-generation programming languages) have features, otherwise it will be stretched when developing medium and large programs.
Although Python supports object-oriented, it does not force you to use this feature. Java is a typical object-oriented programming language, which forces code to be organized in the form of classes and objects. In addition to Python and Java, C, C#, PHP, RuBy, Perl, etc. also support object-oriented features.
In addition to object-oriented programming languages, there is also a process-oriented programming language, the most typical representative of which is C language.
7) Python is powerful (many modules)
Python has many modules, which basically implement all common functions, from simple string processing to complex 3D graphics drawing can be easily completed with the help of Python module.
The Python community is developing well. In addition to the core modules officially provided by Python, many third-party organizations will also participate in the development of modules, including Google, Facebook, Microsoft ) and other software giants.
In Python, even some niche functions often have corresponding open source modules, and there may even be more than one.
8) Python is highly scalable
The scalability of Python is reflected in its modules. Python has the richest and most powerful libraries or modules among scripting languages. These libraries or modules cover most application scenarios such as file operations, graphical interface programming, network programming, and database access.
It is worth noting that the underlying code of these libraries is not necessarily Python, there are also many C/C.
For example, when you need a key piece of code to run faster, you can use C/C language to implement it, and then call them in Python. Python can "glue" other languages together, so it is called the "glue language".
Python relies on its good scalability to make up for the shortcomings of slow running efficiency to a certain extent.
Disadvantages of Python
In addition to the various advantages mentioned above, Python also has disadvantages.
1) Slow running speed
Slow running speed is a common problem of interpreted languages, and Python is no exception.
Python is slow not only because it “translates” the source code while running, but also because Python is a high-level language that blocks many low-level details. This cost is also very high. Python has to do a lot more work, and some work is very resource-intensive, such as managing memory.
Python’s running speed is almost the slowest, not only much slower than C/C, but also slower than Java.
But the disadvantage of slow speed often does not cause any big problems. First of all, computer hardware is shipping faster and faster. Spending more money can build high-performance hardware. The improvement of hardware performance can make up for the lack of software performance.
Secondly, some application scenarios can tolerate slow speeds, such as websites. Most of the time when users open a webpage, they are waiting for network requests instead of waiting for the server to execute webpage programs. It takes 1ms for the server to execute the program and 20ms to execute the program, which is insignificant to the user, because the network connection time often takes 500ms or even 2000ms.
2) Code encryption is difficult
Unlike compiled languages, the source code will be compiled into an executable program (this compilation process is equivalent to encrypting the source code), for Python it is The source code is run directly, so it is difficult to encrypt the source code.
【Related recommendations: Python3 video tutorial】
The above is the detailed content of What type of programming language is python?. For more information, please follow other related articles on the PHP Chinese website!