What is Python? An article takes you to understand Python comprehensively
What kind of existence does Python have in various programming languages? The scope of “various programming languages” is a bit large.
Now, there are more than 600 programming languages in the world, and there are more than 20 popular programming languages. But if you’ve heard of the TIOBE leaderboard, you’ll know roughly how popular programming languages are.
In the “TIOBE April TOP 20 Programming Languages” published by TIOBE, Python ranks first, and this is the seventh consecutive month that Python has occupied the top spot.
Let’s take a look at “TOP 10 Programming Language TIOBE Index Trend (2002-2022)”
Judging from this index trend, the development speed of the Python language has grown exponentially since 2018, and it has obviously not reached a high point.
Finally see the real difference between different programming languages:
Each of the commonly used programming languages has its own advantages and disadvantages. for example:
- The C language can write the operating system’s language close to the hardware, and is suitable for developing programs that pursue running speed and give full play to the hardware performance.
- Python is a high-level programming language used to write applications. Its positioning is “elegant”, “clear” and “simple”, try to write code that is easy to understand and write as little code as possible.
01 What kind of language is Python?
- An interpreted language: There is no compilation in the development process, which can save a lot of time and effort.
- An interactive language: You can write your programs directly interactively at a Python prompt.
- Object-Oriented Language: A programming technique that supports an object-oriented style or code encapsulated in objects.
- Is the language for beginners: supports a wide range of application development.
Let me give you an example: let’s say you want to write an email client.
- If you start from the bottom to write the code related to the network protocol, it is estimated that it will not be developed within a year and a half.
- High-level programming languages usually provide a relatively complete basic code base, covering a large number of contents such as network, file, GUI, database, text, etc., and can be called directly.
That is to say, using a high-level programming language such as Python, an SMTP library for the email protocol, and a GUI library for the desktop environment, based on the existing code base, an email client can be developed in a few days.
In addition to the built-in libraries, Python has a large number of third-party libraries, that is, things developed by others for you to use directly. Of course, if the code you develop is well packaged, it can also be used by others as a third-party library.
02 What types of applications is Python suitable for?
- The first choice is network applications, including websites, background services, and so on.
> > Many large websites are developed in Python, such as YouTube, Instagram, and Douban in China. Many large companies, including Google, Yahoo, etc., and even NASA (NASA) use Python heavily. >
- Followed by many small tools for daily needs, including scripting tasks required by system administrators, etc.;
- The other is to repackage programs developed in other languages for ease of use.
03 What are the advantages and disadvantages of Python?
3.1 Advantages of Python
- 1. Easy to learn: Python has relatively few keywords, simple structure, and easier to learn.
- 2. Easy to read: Python code is defined more clearly than other codes.
- 3. Ease of maintenance: The success of Python is that its source code is fairly easy to maintain.
- 4. Extensive standard library: One of Python’s greatest strengths is its rich library, cross-platform, and good compatibility on UNIX, Windows and Macintosh.
- 5. Interactive mode: The interactive mode is supported, you can input the language to execute the code from the terminal and get the result, interactive test and debug code snippets.
- 6. Portable: Based on its open source nature, Python has been ported (that is, made to work) to many platforms.
- 7. Extensible: If you need a critical piece of code that runs fast, or want to write some algorithms that you don’t want to open, you can use C or C++ to complete that part of the program, and then call it from your Python program.
- 8. Databases: Python provides interfaces to all major commercial databases.
- 9. GUI programming: Python supports GUI can be created and ported to many system calls.
- 10. Embeddable: You can embed Python into a C/C++ program, allowing users of your program to gain “scripting” capabilities.
3.1 Disadvantages of Python
The first disadvantage is that it runs slowly, very slow compared to C programs.
Because Python is an interpreted language, your code will be translated line by line into machine code that the CPU can understand during execution. This translation process is very time-consuming, and the C program is directly compiled into machine code that the CPU can execute before running, so very fast.
But a lot of applications don’t need to run so fast because the user doesn’t feel it at all.
for example:
To develop a network application that downloads MP3, the running time of the C program takes 0.001 seconds, while the running time of the Python program takes 0.1 seconds, which is 100 times slower, but because the network is slower, it needs to wait 1 second, you think, the user can feel To the difference between 1.001 seconds and 1.1 seconds?
The second disadvantage is that the code cannot be encrypted.
If you want to release your Python program, you are actually releasing the source code, which is different from the C language. The C language does not need to release the source code, but only needs to put the compiled machine code (that is, the xxx.exe file you commonly use on Windows). ) published.
It is impossible to deduce C code from machine code. Therefore, all compiled languages do not have this problem, and interpreted languages must release the source code.
This disadvantage is limited to when the software you are writing needs to be sold to others for money. The good news is that in the current Internet era, there are fewer and fewer business models that rely on selling software licenses, and more and more models relying on websites and mobile applications to sell services. The latter model does not require the source code to be given to others.
Besides, the open source movement in full swing is consistent with the spirit of freedom and openness on the Internet. There are countless excellent open source codes like Linux on the Internet. value”. The more important reason why the code of those big companies is reluctant to open up is that the code is so badly written that once it is open source, no one dares to use their products.
Of course, there are several other minor shortcomings of Python, please ignore them and not list them one by one.
Latest Programming News and Information | GeekBar