What are the characteristics of Python? (pros and cons)

Python is an object-oriented, interpreted, general-purpose, open source scripting language. I think there are three main reasons why it is very popular:

Python is easy to use, has low learning cost, and looks very elegant and clean;

Python has many standard libraries and third 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, even 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 C language has to start everything from scratch, while Python already has many common functions built in. We only need to import the package, and then Just call a function.

Simplicity is one of the great charms of Python and its trump card. If you are used to using Python, you can't stand using C language again.

This article will summarize the features of Python and comprehensively compare its advantages and disadvantages.

Advantages of Python

1 Simple syntax

Compared with traditional C/C++, Java, C# and other languages, 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 two typical examples:

(1) Python does not require a semicolon at the end of each statement, of course it is correct;
(2) There is no need to specify the type when defining a variable, and you can even assign different types of data to the same variable.

These 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 programming language with pseudo-code characteristics.

Pseudo Code is an algorithm description language, which is between natural language and programming language. The purpose of using pseudo code is to make the described algorithm easy to write in any programming language (Pascal, C, Java, etc) implementation. Therefore, pseudocode must have a clear structure, simple code, good readability, and resemble 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 will become 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, if we develop a BBS system 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 open source of the Python interpreter and module code is in the hope that all Python users will participate in improving Python's performance and filling Python's loopholes. The more the code is studied, the more robust it will be.

There are 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.

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 automatically manages memory (automatically allocates when needed and releases automatically when not needed).

The advantage of a high-level language is that it is easy to use without worrying 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 used across platforms

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 is a feature that modern programming languages ​​generally have, otherwise it will be difficult to develop medium and large programs.

Python supports object orientation, but it does not enforce object orientation. Java is a typical object-oriented programming language, but it forces code to be organized in the form of classes and objects.

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, all can be easily completed with the help of Python modules.

The Python community is developing well. In addition to the core modules officially provided by Python, many third-party organizations will also participate in developing modules, including software giants such as Google, Facebook, and Microsoft. Even for some niche functions, Python often has corresponding open source modules, and there may even be more than one module.

8 Python is highly scalable

Python's scalability is reflected in its modules. Python has the richest and most powerful class libraries among scripting languages. These class libraries cover most application scenarios such as file I/O, GUI, network programming, database access, and text operations. .

The underlying code of these libraries is not necessarily Python, there are also many C/C++. When you need a critical piece of code to run faster, you can implement it in C/C++ 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 runs slowly

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 speed, such as websites. Most of the time when users open a web page, they are waiting for network requests instead of waiting for the server to execute the web page program. 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, where the source code is compiled into an executable program, Python runs the source code directly, so it is difficult to encrypt the source code.

Open source is a major trend in the software industry, and traditional programmers need to change their minds.

Technical reserves about Python

Here I would like to share with you some free courses for everyone to learn. Below are screenshots of the courses. Scan the QR code at the bottom to get them all.

1. Python learning routes in all directions

Insert image description here

2. Learning software

If a worker wants to do his job well, he must first sharpen his tools. The commonly used development software for learning Python is here, saving everyone a lot of time.
Insert image description here

3. Study materials

Insert image description here

4. Practical information

Practice is the only criterion for testing truth. The compressed packages here can help you improve your personal abilities in your spare time.
Insert image description here

5. Video courses

Insert image description here

Well, today’s sharing ends here. Happy time is always short. Friends who want to learn more courses, don’t worry, there are more surprises~Insert image description here

Guess you like

Origin blog.csdn.net/Everly_/article/details/133339250