Home  >  Article  >  Will PHP finally beat Python?

Will PHP finally beat Python?

藏色散人
藏色散人forward
2021-11-22 11:17:432523browse

Recently, I suddenly found that I seemed to be going against the trend again. Maybe I think differently than many of my friends, but I think PHP, the “bastard” of the programming language world, is more popular than ever.

Maybe you will question - isn't PHP already finished? There are already a lot of “better” programming languages ​​out there, aren’t there?

The answer is obviously no, otherwise PHP would have disappeared from people's sight and would have been stepped on by ten thousand feet. To find the root cause, we probably need to first figure out what the so-called "better" language means.

If you still don’t understand why PHP is still alive and kicking, then we may have to start with issues such as programming, programmers, market and technology popularization. Yes, the real reason is here, not code, functions or syntax.

Once upon a time, scolding PHP represented a trend

If you want to select a team and stand firm in today's coding engineering field, you must first remove the language specified by the leader Let’s first scold all competing programming languages. This has nothing to do with functional features, but a direct reflection of business culture. In other words, such a scene is often reminiscent of an initiation ceremony.

Programmers are a group of stubborn people, including me. We are all arrogant and like to criticize all languages ​​​​that we don’t use or don’t like. You've all heard engineers say, "Java sucks, and C# is garbage and nothing." It doesn't matter what language you're talking about here, as long as it makes everyone laugh.

But there is a deeper disdain hidden behind the wanton denunciation, which is especially obvious in the recent PHP vs. Python debate. In the eyes of many academics, this looks like a bloody dynasty change. It seems that someone wants to kill PHP and completely replace it with Python.

If you don’t believe it, you can check it out on Wikipedia. The “P” in the LAMP stack entry represents Python. Interestingly, when I first came into contact with LAMP 20 years ago, the "P" definitely referred to PHP - yes, neither Python nor Perl. I'm not saying things can't evolve, but how did Python unknowingly replace PHP's cultural status? This is indeed a question worth pondering.

For most programmers, we will learn Python in school and other niche languages ​​​​that may never be used in real-world scenarios. You will more or less hear professors or other practitioners say things like "PHP sucks", but if we dig deeper, we will find that they may have never seriously written even a line of PHP code.

In fact, just thinking about someone writing PHP code full-time gives us chills, just like seeing the devil Satan actually has loyal followers.

This disdain for PHP is actually quite logical, and has even formed an endogenous consensus among the programmer community. Wouldn’t it be nice to sit down with your friends and enjoy an afternoon at Starbucks while talking about Trump, pop rock, and PHP?

There are also programming purists who are willing to waste a lot of valuable time arguing why PHP really sucks. Most arguments revolve around some design trend or nuance that they don't like, and back-and-forth is a common tactic in these types of exchanges. As for language, we have to judge who is superior and who is inferior. After all, the purple and gold gourds are divided into male and female.

There is indeed a lot to complain about: PHP is a loosely typed language, so it often breeds bad code. (But the same goes for JavaScript and Node.js. Why don’t you see so much resentment?) PHP has too many functions. (Yes, this is too convenient and does not show off the level of a programmer.) Function names are inconsistent. (Yes, such a problem will arise when a language is truly popular and is not entirely in the hands of a single computer science PhD.)

Let’s return to the topic, you can see Criticisms of PHP mostly stem from personal preference or cherry-picking of details. If we wanted to, we could find similar faults in other languages ​​such as Python, C#, Java, Go, or JavaScript. As programmers, we just love to complain, and complaining makes us happy.

But the real reason why programmers love to bash PHP is because of our inherent arrogance mixed with ever-expanding jealousy.

PHP is indeed easier to use

PHP was born in the mid-1990s, and is even older than many strong programmers. I started working with PHP in the early 2000s, when it was just transitioning from version 4 to version 5. Later, I started writing applications in the CodeIgniter ZendFramework framework that I wrote.

In my opinion, the main reason why PHP can remain evergreen and show no signs of aging after many years is that it is embedded in new and old applications all over the world, and it is also embedded in the minds of developers regardless of age. Some people have used it for a few years, and some have used it for decades, and PHP has left a deep impression on them. Developers will not disappear, nor will the business code they write, so PHP is still here to stay. And interestingly, Python was actually born in 1991, earlier than PHP. And despite its longer life cycle, Python has never been able to reach the current heights of PHP.

Why is this?

From a personal point of view, I think Python is more troublesome to use than PHP. This problem has improved in Python 3, but going back 15 years, Python didn't have those "fancy features" (functions) that came out of the box in PHP. Many features must be installed manually, otherwise they will be useless.

And another long-standing problem that has pervaded the Python language for a long time is the interval syntax. I really hate this syntax where the number of spaces between codes determines the separation. I like to separate my code however I like, and can't stand the programming language itself having to use its brain here at all. Everyone is free to criticize this habit of mine, but this is my own code and written by me. Is it wrong to want to follow my own style? If you are not given even this right, I will curse the self-righteous trolls who check bugs every day.

Python has always boasted that this spaced syntax is "easy to read", which is obviously marketing bullshit. I'll leave it at that - the syntax used by Python can be called the most self-righteous and worst syntax in the programming language world.

It is this incomprehensible self-righteousness that makes programmers suffer; in the early days of programming, when there were no IDEs to help us correct grammatical errors, there were not many programmers willing to Take a closer look at Python. Anyway, I don’t want to. To be more precise, this is also a major reason why the Python language has not been able to gain a significant market share in the first ten years of its existence. Yes, this design is not user-friendly at all.

In addition, the presence of the Python language is not strong. It is embedded into the Linux distribution as a scripting language, which is its main purpose. No one will cheer "Yeah, Python is here, we can use it to build websites!"

Of course, Python can also be used to build websites, but excellent engineers can feel that its characteristics are not suitable Web development scenarios. Personal syntax-level preferences aside, I admit that Python is an extremely powerful language, especially suitable for handling data science or other tasks that focus on high-precision mathematical operations.

Everyone can get started with PHP

In the past 15 years, Python has indeed ushered in a radical update, so it has surpassed PHP on many levels. But Python still has two heavy baggages that haven't been thrown away: First, most updates appear ten years too late.

Python 3 was released in 2008, breaking backwards compatibility. Python 2 code will not run with Python 3 without additional modifications. But in an enterprise environment, there are often dozens or millions of old versions of code. Who is willing to go to this trouble?

To be fair, PHP 7 and 8 also break some PHP 5 (there is no PHP 6 version) code. I was part of the ZendFramework community, which has been helping to update the framework to support running on PHP 7 and 8 for older code. The good news is that our legacy code was barely affected when upgrading ZendFramework to PHP 7 and 8. Therefore, most PHP 5.6 code has good backward compatibility.

Perhaps the watershed event that really made PHP an evergreen tree in the industry was the quiet establishment of a small start-up called Automattic in 2005.

If WordPress was written in Python, I can guarantee that PHP would never be as proud as it is today. But I also dare to say that Python will hinder or even kill the possibility of WordPress becoming as widely successful as it is today.

For a language or application to continue to survive in the open source market, the use and expansion of contributors are crucial. And whoever is easier to get started will be able to attract more support from contributors in the industry.

As a software engineer with professional training, I can try to understand all the insults directed at PHP, but I would like to remind everyone that PHP is not only used by engineers with formal diplomas, but also by part-time workers. , housewives, graphic designers, company managers, entrepreneurs and even elementary school students. That’s right, thousands of elementary school students are writing web pages in PHP on their first computers.

It can also be said that PHP is the BASIC language in the information age.

As software engineers, many critics have become accustomed to the way of thinking of engineers, but they forget that there are countless PHP users in the world who just want to build a website for a small company and have limited time and resources.

WordPress and PHP opened their arms to them. Yes, WordPress itself is indeed easy to use, but it’s not comprehensive enough. What supplements this shortcoming is the WordPress plug-in architecture (the word "architecture" may not be accurate here, but everyone can understand it), which allows ordinary people to write a small piece of code in PHP to implement corresponding changes. There is no need to rewrite the entire class, and there is no need to take any software engineer certification. It only requires a small piece of code.

In this way, millions of amateur programmers have embarked on their own programming path and shared their experiences with others on the Internet, eventually establishing a huge PHP technology community.

Easy-to-understand PHP allows ordinary people to write code effectively. It is simple, temperless, loosely typed, does not involve compilation, and can be said to be easy to work with.

PHP supports the entire World Wide Web

Fast forward to 15 years later, and today PHP supports 78% of web systems. WordPress alone accounts for nearly 40% of all websites and owns nearly two-thirds of all CMSs! What's more, the "prestigious" Python only accounts for 10% of the pie! Despite the hatred of PHP among rival Python diehards, Python powers less than 1.5% of the web.

Are you angry? There's nothing to be angry about.

Yes, it should be so.

I have been contacted by a recruiter from a corporate client who expressed his intention to delete all Python web code and replace it with PHP. This sounds amazing, but it actually happens all the time. Why? Because there is a saying that Python is not very suitable for web applications. Developers familiar with Python are often experts in data science and other fields, and experienced talent is in short supply. It's quite unnecessary to let them engage in web development.

Businesses want to be more flexible on the Web. When they need to expand or reduce the size of their team, they don't want to spend weeks or months slowly looking for talent who is familiar with Python. This type of engineer is very expensive, and companies cannot afford it.

However, PHP programmers who can adapt to different business sizes have high quality and quantity in the labor market, and can even be trained quickly as needed. More importantly, even if you want to find an experienced senior PHP architect with decades of experience, it is far less difficult than finding someone of the same level in the Python field.

And the company management will also teach Python fans how to behave. Do you want to write web or middleware in Python without a hard-and-fast reason? People simply don’t have that much budget, and they require easy replacement with other tools at any time. These are things that Python is not good at.

To become a qualified application architect, the first thing is to learn to use the most effective technology to provide "appropriate scale" support for the business or enterprise: our personal preferences are not important, and the technology is not important. , the most important thing is more, faster, better and more economical.

So I found that there are actually very few SaaS applications suitable for writing entirely in Python. Given Python's pitiful market share on the web, it seems that most application architects share my opinion. They use Python only where it fits best, and PHP where it fits even more.

Summary

As engineers, we all like to use things we are familiar with, and we are also used to belittling things we don’t understand. Don't be afraid to admit it, we programmers have this problem.

Colleges have been trying to position Python as a general-purpose business language - but it is not. Python is better suited as a high-end language, specialized for running servers, data science, handling large-scale complex data, or even handling cryptocurrency mining. These are its specialties.

PHP is a popular language and has become an objective standard on the World Wide Web.

So if you want, you can continue to badmouth PHP, it doesn't matter. But at the end of the day, it's still the most widely used language on the web, and as WordPress continues to grow and PHP 7 and 8 continue to be upgraded, that leadership won't be shaken anytime soon.

About the author:

Beau Beauchamp is an enterprise-level UI/UX full-stack web application architect and senior developer with more than 20 years of experience in developing scalable applications.

Original link:

https://beau-beauchamp.medium.com/php-is-killing-python-2be459364284

Statement:
This article is reproduced at:toutiao.com. If there is any infringement, please contact admin@php.cn delete