Home  >  Article  >  Backend Development  >  Why is PHP a concentration camp_PHP Tutorial

Why is PHP a concentration camp_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 14:51:53762browse

This article is translated from the article Why PHP Was a Ghetto.

One day I was chatting with the boss of a great startup company in DUMBO and talked about why developers in the non-PHP world generally despise PHP and PHP-related communities. He made a point that stuck with me, largely because I had never heard it made like this before.

If you don’t know what complaints most programmers have about PHP, then these complaints would look something like this:

Ugly syntax

Lacks some necessary features that other languages ​​have (before version 5.3, no namespaces, closures)

Inconsistent function naming, usage conventions, and other weird stuff

A mixture of procedural and object-oriented

Basically 80-90% of PHP projects suck like a pile of shit

But the problem with PHP he mentioned is another problem. He doesn't say there's something wrong with the language - he thinks the language is surrounded by a common cultural phenomenon, a cultural tradition usually created by the creators of the language, which now seems to be responsible for some bad programming practices. The method played an encouraging role. That is, it makes PHP code inferior and unmaintainable.

This phenomenon of a language or framework that embodies the founder’s philosophical thoughts and is highly praised by the relevant community does exist. He cited Ruby and its founder Matz as examples. What Matz wanted was a language that was easy to read and write and could improve programmers' work efficiency. Don’t you see how Ruby developers talk about rapid development and the elegance of the language?

Then there is DHH and his Rails framework. And Guido and his Python language. So I was thinking: RasmusWhat about PHP?

Rasmus Lerdorf’s impression is very interesting. He created the original PHP language and has been improving the language. He is worshiped like a god in the PHP community and he enjoys the greatest authority in any aspect of PHP. He was invited to speak at numerous conferences and was hired by a large Internet company (yahoo.com), where he gained everyone's respect - despite the fact that he became the target of most non-PHP programmers. A visual representation of the many problems that despise PHP.

Rasmus advocates avoiding the use of frameworks and treating PHP more as a template language. To him, this approach yields immediate operational efficiency and scalability (the program load is known). For everyone else, this approach resulted in a simmering mess of procedural code and an unmaintainable project. In the approximately 10 years since PHP was born in 1995, all PHP projects have been written according to this guidance.

At the same time, another problem suddenly appeared: before PHP5.0, in the early days of PHP, PHP gained a large number of novice followers. The barrier to entry for this language is surprisingly low. Anyone can download the self-extracting ×AMP Windows program installation package and start using the language within 2 minutes. In addition, there was no real consensus on the MVC pattern in web development methods at that time. So you can imagine what a group of novices can create when they come together with a language that lacks good development practices. An unmaintainable pile of garbage. And the entire environment is like this.

Don't get me wrong - there were still a lot of good PHP developers, even back then. But, like I said, shoddy rookie work is everywhere. When cowboy-style PHP programmers got together to develop programs without guiding principles, the likes of PHPbb, PHPNuke, and many crude .php3 packages emerged. But can you simply blame PHP developers? cannot! Other Web language giants, ASP and Perl, are equally notorious and promote a stew-style development approach.

So this is why PHP gets such a bad rap. It's because of its historical spread. Most PHP developers who had moved to Python, Ruby, and Java did not go back and rethink the language when the MVC concept emerged. In addition, there are some explicit satires like "Ruby boy" Zed Shaw complaining that some programmers' minds are "poisoned by PHP". Comments like this are very popular on RubyInside.

PHP is a concentration camp

But the emergence of frameworks like Zend and CodeIgniter has pushed the language in the right development direction. In fact, it pushed PHP in the opposite direction from what Rasmus wanted to see. Take a look at the Zend and CodeIgniter frameworks, and you will find that they are one of the few programs with well-written documentation and well-written code.

Most developers who learn Ruby also learn Rails and MVC knowledge; PHP has been used for a full 10 years before this. For those who are new to Ruby, it's a shame that Ruby doesn't give them this time to play freely. Rails has ready-made standard guidance, and its entry barrier is relatively high, which usually blocks out some inexperienced developers.

In fact, PHP applications can be written as well as other languages, and they will also have certain advantages in running speed. The rise of the MVC-style development method in the PHP world has only appeared in recent years. We have to admit that we should be grateful to Rails for bringing this change.

So, what does PHP look like today?

Various standards (not unified, but most projects use MVC, few junk procedural programs)

Low entry barrier

Speed ​​and scalability (PHP should be the best among various scripting languages)

Have a good unit testing framework

Have the best documents translated into various languages

In addition, most influential websites on the Internet use PHP as their backend language or tool, such as Facebook, Digg, Wikipedia, WordPress, Drupal, etc. I believe that having an in-depth mastery of PHP will open the door to more unknown areas for a programmer.

If you don’t agree with what’s said above, please leave a comment or email me – I’d like to hear why you don’t think so.

In fact, I am not a PHP fan, I have no feeling for the language. I mostly use PHP because - you guessed it - someone is willing to pay me. So blame it all on this:

If you want to make informed decisions in software design, PHP is your best choice for developing web applications.

By the way, if you are convinced that you want to use PHP to develop your next web application, give CodeIgniter a try. It is a lightweight, plain and super fast PHP framework. I'm a fan of CodeIgniter.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371713.htmlTechArticleThis article is translated from the article Why PHP Was a Ghetto. One day I was chatting with the owner of a great startup in DUMBO and talked about why developers in the non-PHP world generally...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn