Liuxingyuan Classroom: When will Python be phased out? What are the fatal flaws of Python?

thumbnail

It took decades for Python to be appreciated by the programming community. Since 2010, Python has flourished and eventually surpassed C, C#, Java, and JavaScript.

But how long will this trend continue? When will Python be replaced by other languages? What is the reason for being replaced?

There’s been a lot of speculation about the exact date Python will be phased out, and it could be a thing of the past like science fiction. In this article, I’ll discuss the strengths that contributed to Python’s widespread popularity, and the weaknesses that will lead to its demise in the future.

Factors contributing to the popularity of Python

The success of Python can be seen through Stack Overflow trends. Given the size of StackOverflow, we can consider this a good indicator of programming language popularity.

While R’s development has been plateauing over the past few years and many other programming languages ​​have started to decline steadily, Python’s growth seems unstoppable. 14% of all StackOverflow questions are tagged with “python”, and the trend is rising. There are many reasons for this.

Python is an ancient language

Python came out in the 90s. Not only does this mean Python has plenty of time to grow, but it also has a large support community.

So, if you have any problem programming with Python, just search the internet and you will get the answer. Because there will always be someone who has run into this problem before and has written some useful material about it.

friendly to beginners

Python is beginner friendly not only because it has been around for decades, giving programmers enough time to write great tutorials, but also because Python’s syntax is very easy to understand.

First, there is no need to specify the data type. All you need to do is declare a variable, and Python will determine whether the variable is an integer, float, boolean, or some other type based on the context. For beginners, this is a huge advantage. If you’ve ever programmed in C++, you’ll know how hard it is for a program to fail to compile just because you’ve mistakenly defined a floating-point number as an integer.

Also, comparing Python and C++ code, it’s not hard to see how easy Python is to understand. Even though C++ was designed with English in mind, reading C++ code is quite bumpy compared to Python code.

Wide range of uses

Since Python has been around for a long time, developers have created various packages for it. Today, no matter what the problem, you can find the relevant package.

  • Want to work with numbers, vectors and matrices? Then try NumPy. Want to do technical and engineering calculations? Then try SciPy. Want to manipulate and analyze big data? Then try Pandas. Want to learn artificial intelligence? Why not try Scikit-Learn.

No matter what kind of computing task you need, you can find relevant Python packages. Due to the rapid development of machine learning in the past few years, Python has been at the forefront of the development of the times.

Python’s shortcomings, are these shortcomings fatal?

From the above discussion, you can imagine that the development of Python has been unstoppable for a long time. However, Python cannot escape the fate of all technologies, and it also has its own weaknesses. Next, I will go through the major flaws of Python one by one and assess whether these flaws are fatal.

speed

Python is slow, very, very slow. On average, it takes 2–10 times as long to complete a task in Python as in any other language.

There are many reasons for this. One of them is because Python is dynamically typed, don’t forget that you don’t need to specify data types like other languages. This means that the memory consumption is very high, because in any case the program needs to reserve enough space for each variable. And the huge memory usage will inevitably consume a lot of computing time.

Another reason is that Python can only perform one task at a time. This is a consequence of flexible data types, Python needs to ensure that each variable has only one data type, and parallel processes can go wrong at this point.

By comparison, a normal web browser can run a dozen different threads at a time. Of course there are other factors involved.

But in the end all speed issues don’t matter. Because the prices of computers and servers are getting lower and lower, we are only talking about fractions of a second. End users don’t really care if it takes 0.001 or 0.01 seconds for their app to load.

scope

Originally, Python was dynamically scoped. This basically means that, in order to evaluate an expression, the compiler first needs to search the current block and then all the calling functions in turn.

The problem with dynamic scoping is that every expression needs to be tested in all contexts, which is tedious. This is why most modern programming languages ​​use static scoping.

Python tried transitioning to static scoping, but screwed it up. Often, inner scopes (such as functions within functions) are able to see and change outer scopes. In Python, inner scopes can only see outer scopes, but not change them. So it caused a lot of confusion.

Lambdas

Although Python is very flexible, there are certain limitations to the use of Lambdas. Lambdas can only be expressions in Python, not statements.

On the other hand, variable declarations and statements are always statements, which means they cannot use Lambdas.

In Python, the distinction between expressions and statements is rather arbitrary, a problem no other programming language has.

blank

In Python, you need to use whitespace and indentation to represent different levels of code. The format is visually appealing and easy to understand.

Other programming languages, such as C++, rely on braces and semicolons. While this may not be as visually appealing and beginner friendly, it improves code maintainability. In large projects, this approach is more appropriate.

Emerging programming languages ​​such as Haskell solve this problem: they rely on whitespace, but at the same time provide an alternative syntax for those who prefer not to use whitespace.

mobile development

We’ve witnessed the shift from desktops to smartphones, and it’s clear that we need powerful languages ​​to build mobile software.

However, there are not many mobile applications developed using Python. This does not mean that Python cannot develop mobile applications, you can try a Python package called Kivy.

However, Python was not designed with mobile devices in mind. Therefore, even though Python can handle basic tasks, we are better off choosing a language that was created specifically for mobile application development. Languages ​​widely used for mobile programming include: React Native, Flutter, Iconic, and Cordova.

We need to be clear that laptops and desktop computers have been around for many years. However, since the use of mobile devices has surpassed desktop devices, we can safely say that learning Python is not enough to become an experienced all-round developer.

runtime error

Python does not need to be compiled first and then executed. Instead, it compiles on every execution, so all programming errors show up at runtime. This results in slow performance, wasted time, and requires extensive testing.

This isn’t necessarily a bad thing for beginners, as tests can teach them a lot. However, for experienced developers, having to debug complex programs in Python can be a headache. Lack of performance is Python’s biggest problem.

When will Python be replaced?

Today, new competitive forces are emerging in the programming language market:

  • Rust offers the same safety as Python - no variables are accidentally overwritten. However, it solves the problem of efficiency through the concepts of ownership and borrowing. According to StackOverflow Insights, Rust is the most popular programming language in recent years. Go is as beginner-friendly as Python. The language itself is very simple, and maintaining the code is even simpler. Also, interestingly, Go developers are some of the highest paid programmers on the market. Julia is a very new language that competes head-to-head with Python. Julia fills a void in large-scale technical computing: previously, one would typically have to write code in Python or Matlab, and then patch the whole program with C++ libraries, which are essential at scale. Today, one can use Julia without having to struggle between the two languages.

While there are other languages ​​on the market, Rust, Go, and Julia can make up for Python’s weaknesses. All of these languages ​​excel in upcoming technologies, most notably artificial intelligence. Although their market share is still small, there is a clear upward trend in the development of these languages, according to StackOverflow.

Today, Python is everywhere, and it will be five years or more before we will likely see Python replaced by a new language.

For now, it’s hard to tell which language is likely to replace Python, Rust, Go, Julia, or some other new language. But given the most basic performance issues in the Python architecture, it will inevitably be replaced by humans.

The above is all the content shared this time. If you want to learn more Python skills, please continue to pay attention to Liuxingyuan Classroom!

Latest Programming News and Information | GeekBar

Related Posts