PHP is out? It's too early to see PHP being eliminated!


The full text has a total of 6214 words, and the expected learning time is 16 minutes

Source: Google

I have been writing this article for a while, and I have changed here and there, but I just don’t know when it will be published. The recent release of PHP 8 makes me feel that now is "the time."

 

Every month I see people saying that PHP is gradually becoming obsolete and that we should not be using it. If you see a question about "learning PHP" on some forums or Stack Overflow, 100% of you will see someone post something like "Why do you want to learn PHP? Isn’t it good to learn something, for example, “a certain cow language” '" remarks.

 

I have written PHP for almost 20 years (maybe longer, I don't remember when I started). When using other languages, in most cases, I will simply ignore most of the conversation. Over the years, PHP has gradually "lost its vitality", and I shouldn't use it long ago. I am not an expert in any language. I still have a lot to learn about PHP, but I find myself choosing it again and again.

 

When I occasionally read some well-written articles that advise people not to use PHP, I was almost convinced, so I spent a lot of time learning other languages. I must admit that these explorations have made me very rewarding. Although I may never reach the expert level in using it, by learning other languages, I have a deeper understanding of the profession of programmers.

 

If there is anything to learn from this article, it is: learn a new language. But it is not because "PHP has lost its vitality"-this is a wrong view. You have to learn other languages ​​because it is good for you as a programmer. If PHP is really out of the question, then you should learn other languages. But at this moment, it has not lost its vitality.

 

For many programmers who write PHP, when they need to defend their choice, they may be the first to show some tables, these tables show the popularity of PHP in the whole network. Although these numbers are very encouraging, I still suspect that they are misleading.

 

We must realize that PHP is popular because people love WordPress. Whether you like WordPress or not, you must admit that its existence is crucial. But to be honest, WordPress still has many flaws, and many of them. But I know that many people use WordPress to accomplish many amazing things and make a lot of money.

 

PHP is not WordPress, even though WordPress is deeply rooted in the soil of PHP history, PHP is much better than WordPress, much better. WordPress has many shortcomings, PHP also has many shortcomings, but this does not mean that they are not suitable for all projects.

 

I generally don't use C++ to write network programs, at least it will be at the end of my choice list. But this is not to say that C++ is a bad language, it is just not applicable. Just like I don't use PHP to write hardware drivers or anything related to AI, this is beyond its ability.

 

The choice of languages ​​is of course also closely related to your own mastery of them. As the old saying goes: time is money, and it is often difficult to carry out a project in a newly learned language, which will make the already tight time worse.

 

I am familiar with PHP, so I tend to choose it first. I know a little bit of Python, but I am much more comfortable writing PHP. I can also choose Python for the same task, but it may take twice as long (at least at first). This is not to say that I will never use Python or I am dissatisfied with Python, but that PHP is my first choice.

 

Learning a programming language is not that difficult. An experienced programmer may master the essentials of a language in a weekend. But this does not mean that they understand the language. Knowing which built-in function does what is not called understanding a language, you must have enough experience to know when to use what features, or to know how the entire ecosystem is integrated.

 

I know PHP, but I also know how to set up an Nginx web server, how to configure FPM or opcache. I have enough to get rid of the influence of dependence and make the right choice. I know how to safely deploy PHP applications in a production environment, and I know that if you accidentally use certain language features, it may cause security problems. These things are more than just "knowing" a language. As programmers, we need to invest a lot of time to learn things outside of these languages ​​of our choice.

 

This is why when some programmers say that your language of choice is "garbage", I will be very disappointed. I have spent twenty years honing the skills in this area, but now someone has come to tell me, my choice is wrong?

 

In fact, this is not a wrong choice, PHP has brought me a satisfactory job. The reason why I can live in a beautiful house and drive a luxurious car is precisely because I have spent 20 years proficient in PHP. I'm going far, and I should continue to talk about why PHP is not rubbish.

 

Many people who hate PHP and think it should be eliminated will list many points to prove that PHP is the wrong choice. There are many views that we have been hearing in the past few years are aimed at the ashes version of PHP (I don't know why everyone is still holding on to PHP4, what's up?).

 

Some points are simply nonsense and even wrong. This is not a contest for "My programming language is better than you". There is no need to be hysterical. I believe in my heart that every programming language has its own mission. Those who invent these languages ​​(that is, those who are much smarter than me) invented these languages ​​for a reason. Programming languages ​​are not something that can be made casually.

 

Source: unsplash

So, why choose PHP?

 

The answer is clear: because it is there. I taught PHP by myself and I haven't participated in many formal trainings. Except for the occasional online training courses, I don't have a famous university diploma with "I can teach computers to do things".

 

I have a background in design. Although I have been fiddling with code and computers since I was about seven years old, I don't have the same enthusiasm for receiving this education. I don't even know why. I love computers and the Internet, but I chose graphic design. I don't want to repeat the content in this area, because although I have this degree, it has not played a big role in my work today.

 

I believe that, like most PHP programmers, I started using PHP because we wanted the website to do more than just display a picture and a paragraph of text. When I learned how to extract the data from the database and display it on the web page, I was so excited, it was so exciting! This is exactly what I wanted, so I plunged in.

 

Later, I came across WordPress. Just like those self-righteous people who are sitting in front of a computer screen and know a little PHP basics change everything, WordPress changes everything. The success of WordPress can be attributed to people like me. Young people like us want a blog of our own but don't know how to build it ourselves.

 

You installed WordPress...then added a plugin, changed the theme...and then you made some small changes to the theme, so it accomplishes some other things, or looks a little different. Then you modified a plugin. Then you create your own theme. Then you are thinking, what else can I do?

 

So I got to know PHP. It was not that I chose PHP, but that PHP chose me. Twenty years later, I am still creating things with PHP, and I no longer need WordPress. I think I am already a mature PHP programmer and have the ability to write this article.

 

 "PHP is too simple, you should learn something challenging"

 

One of the important reasons why PHP is so popular is that it is everywhere and is installed everywhere. Even your most common MacBook comes with PHP pre-installed, hell.

 

Writing PHP from scratch is also very easy, and usually there is nothing special you need to do. Create an index.php file, put a line of PHP code in it, and upload it to almost all shared hosting accounts:

 

<?phpecho  Hello, World! ;

Then it's done. Getting started with PHP is really easy, you don't need to know how it works. You are done with peace of mind. However, if you believe it, the "easy operation" of PHP may actually be a disadvantage. In theory, if PHP is so simple, it is also very easy to write dangerous code in PHP.

 

The thought of this made me a little fidgety. Does this mean that people are unlikely to use those difficult languages ​​to write dangerous code? Where did I read that about 70% of the fixes Microsoft released for Windows are to solve the memory problem caused by C++ (this is not what I said). I suspect that people who write Microsoft in C++ are amateurs, and I'm pretty sure they know what they are doing.

 

Yes, although Windows is much more complicated than the shopping cart website you use, I think this view is tenable. Python is recognized as a beginner-friendly language, but no one says it is "dangerous". It is easy to write any dangerous code in any language. It's not that language creates dangerous code, but lack of relevant knowledge creates dangerous code.

 

 "Simple" is not a reason to dissuade novices from learning PHP. On the contrary, it gives beginners better tools so that they can make better choices when writing code. This is also the reason to help them find the right resources to learn PHP correctly. I'm lucky. Even though I have written a lot of "dangerous" code, there will always be some noble people (not necessarily PHP engineers) on my way to learn to help me find areas for improvement.

 

PHP is slow

 

Source: unsplash

Not really. PHP can synchronize the speed at which you write code. PHP is a scripting language, so it is meaningless to compare it with a compiled language, but for some reason, I have seen people even compare PHP with Rust or Go. These comparisons are not interesting.

 

It may be better to compare it with python or Ruby, but the "speed" of a language is determined by many factors, such as the language itself, the environment, the code that runs, the way the interpreter is configured, and so on. It is not enough to say that PHP is slow in a vacuum.

 

For certain types of tasks, PHP is really slow. For example, if you are working in the field of machine learning, you may not prefer PHP (although there are some interesting projects that are showing some promise).

 

Sometimes you will see some benchmark tests where two languages ​​do the same thing, such as looping over 1 million records and doing some simple calculations. The results often differ by a few milliseconds, which is often used to prove that PHP is slow (and sometimes to prove that it is fast). If you write software that takes a few more milliseconds to cause catastrophic results when looping through one million records, there is nothing to say.

 

WordPress is rubbish

 

I quite agree with this view. Currently I don't like WordPress very much, but I also admit that without WordPress, we probably won't have the PHP community we have today. However, because one software speaks one language is not good and a bit sloppy. It's like saying that C++ is a rubbish language because you don't like Microsoft Windows.

 

PHP is not only one function, WordPress is only a part of it. If you want, there are plenty of frameworks and packages for you to choose from. People say Laravel is "make PHP cool again". I must admit that this framework is by far one of my favorite frameworks, and it is the easiest for me to choose it in most projects.

 

Because WordPress is written in PHP, it is unfair to say that PHP is not good. Some people might say that WordPress reflects the limitations of PHP, but that was a long time ago, and the language has matured a lot since then.

 

PHP is not suitable for enterprise use

 

why? I don't know where this kind of speech comes from, but it's really strong. So what makes a language "suitable for business"? Java may be one of the most popular languages ​​for enterprises, but it is not because Java itself is suitable for enterprises. Because of the existence of the Java EE platform, I am not a Java developer, so please correct me if you have any mistakes.

 

In my opinion, Java is a platform for building enterprise application software. It sounds a bit like a frame, right? So maybe the question should be: "Is my favorite PHP framework suitable for enterprises?"

 

To answer this question, I need to write another article. The point I want to say is that PHP, like any other language, is adequate for enterprise use. It all depends on how you use it.

 

By the way, I used to be a member of a small team that built and deployed an event management platform on the internal network of one of the most important financial institutions in South Africa (I might write about my experience in this area). The application is written entirely in PHP and JavaScript.

 

With the full-scale outbreak of the new crown epidemic, the entire system is under tremendous pressure, but it has dealt with almost all the pressure. We also encountered some problems, but they were all resolved quickly.

 

PHP is not scalable

 

This may be the only point with a bit of evidence, but it is more complicated than you think. In fact, if you write decent code, PHP can scale well. When people say that PHP is not scalable, they usually mean that an application written in PHP may not be able to handle a very large number of requests (say millions).

 

The problem is that this is not so simple. I think a lot of misunderstandings about it come from WordPress. Recently, WordPress is famous for its scalability issues.

 

For example, Slack is a communication platform that once wanted to get email. It has millions of users. The backend of the system they use every day is written in PHP. If this does not mean that PHP is extensible, then I have nothing to say.

 

Many people cite Facebook as a good example. Even though I think Facebook still uses PHP in some forms, most applications don’t use PHP. But to be honest, this example of Facebook is a bit special.

 

Talking about scalability cannot go without infrastructure. If you host a WordPress blog on a simple shared hosting, and suddenly you get thousands of clicks...this may be a problem, your host will send you an annoying email, or at least it will Billing you far more than you expected.

 

Expanding an application involves more than just language selection. There are many changes, and I feel sad whenever PHP is blamed first. In a suitable environment and configuration, the new version of PHP can handle a large number of requests per second. Laravel Vapor is a first-party serverless platform for Laravel applications running on AWS, and it has some very impressive numbers.

 

I sometimes think that the issue of scalability is a bit exaggerated. I have written PHP for more than 20 years, and I have never encountered a situation of "millions of requests" per second. There is not even a similar situation. Most of us have no chance to build the next Facebook, no matter how much we think about it.

 

In reality, the software we build is much more targeted. We are dealing with specific industries in specific countries, so we don’t have to worry about facing millions of requests per second. For many of the projects we have participated in, this is a huge number. This does not mean that what we do is unimportant, it just means that we don't need to think about that scale, and scaling an application to handle millions of requests is not part of our daily work.

 

PHP is so ugly

 

Are you kidding me? I will leave the most annoying point to the end. If you choose the technology stack based on appearance, then I want to say that you are wrong, you really need to re-evaluate your choice.

 

That being said, I think PHP is not ugly at all. Some people think it’s not good-looking, it’s probably because they used PHP in HTML a long time ago, and HTML is really ugly. The problem is: no one does this anymore, and someone else will be disgusted if they do it.

 

I am not saying that the so-called "beautiful language" is a bad choice, but "looks good or not" should not be your evaluation criterion. Java is very ugly, but it is one of the most popular languages ​​in the world. It is really silly to preach not to use PHP because it is ugly.

 

PHP may not be the most beautiful language, but I find it is very readable if written well. PHP8 also has some new tools that can make your code look more "beautiful".

 

Source: unsplash

I love php

 

I really love PHP. I love this programming language and its ecosystem. I love its improvement over the past few years, PHP 8 is not just another iteration of the same language. With the release of each major version, we get better and more useful tools.

 

I like the ease of use of PHP, but I also like its complexity. There are so many things to learn to become a professional PHP programmer. I like Symfony and Laravel. I think the development team, as the core of PHP, has been promoting the progress of this language.

 

But my favorite part is being a programmer. Not only writing PHP, I like writing in any language. I like that I can tell the computer what to do and I taught myself how to do it. This is thanks to PHP.

 

Without PHP, I don't know what kind of work I would do now. Maybe I will become a mediocre designer, and then hate my work and life (not to offend the designer friends, I also have some talented designer friends who love their work very much).

 

But in the end, I used my favorite programming language to do what I love.

 


Recommended reading topics

Leave a comment, like, send a circle of friends

Let's share the dry goods of AI learning and development

Compilation Team: Zhang Yuexing, Ji Xing

Related Links:

https://medium.com/swlh/stop-saying-php-is-dead-9489ed7dc25e

If reprinting, please leave a message in the background and follow the reprinting specifications

Recommended article reading

50 Interpretations of ACL2018 Proceedings

Interpretation of 28 Papers in EMNLP2017 Proceedings

Full links to China's academic achievements in the three top AI conferences in 2018

ACL2017 Proceedings: 34 interpretations and dry goods are all here

Review of 10 AAAI2017 classic papers

Long press to identify the QR code to add attention

Core reader loves you

Guess you like

Origin blog.csdn.net/duxinshuxiaobian/article/details/112646042
php