In defense of PHP
- Transfer
Recently, a topic was created on stackoverflow in which the author claimed that PHP was a non-important language and asked to convince it. As arguments, he cited several arguments that were sequentially commented on by another participant. A free translation of this is presented below.
Personally, I completely agree with the responder and I think that all PHP haters should familiarize themselves with the following.
This is what I love and hate at the same time. However, in essence, this statement is true. Why are some two-word functions separated by underscores and some not? Why do $ needles and $ haystack sometimes swap places? This is ridiculous. But in the end is it really that important? My auto-IDE and php.net are always at hand. So maybe this is a negative factor for PHP as a language. But it does not stop me from being an effective programmer.
Personally, I think this is not a very good point. Such changes are necessary for the evolution of the language, especially for the one used on a large scale, like PHP. PHP provides a lot of opportunities to become a bad programmer, but in the same way, it is difficult for PHP developers to eliminate stupid language constructs, such as passing a value by reference. Eliminating this opportunity has become one of the best decisions they have ever made. For a beginner, there is no simpler way to shoot yourself in the foot than using this “function."
I do not think that there is any flaw in the logic. I think that this particular change strongly affected you and "there was an unpleasant aftertaste in your mouth." Changes in the language often become known months or even years before their implementation. To go from 4 to 5, there is a migration guide that describes all the differences. Passing parameters by reference was a terrible trait that did not give the developer any advantages that could not be achieved in other ways.
I have mixed feelings about this. Part of me thinks, “what's the difference, because the escape character does not make sense outside the line”, and part of me thinks “they probably could have come up with something better”. But could they? I don't know, I'm not a Zend developer. However, the fact that we have no namespaces before 5.3 is a terrible omission.
I consider it normal to disagree with how PHP does this, but I do not agree that this makes the language "bad."
PHP is a DSL for the web. I worked closely with him for 8 years and used recursion on the strength of 4 or 5 times, usually to bypass directories or XML. This is not the approach often needed for web development. I do not condone low productivity, but this is a much more academic issue than productivity. If you really need fast recursion, PHP is not your choice.
I 100% agree with that.
How wonderful - people complain about a language that allows them to use any output system (this is eloquently evidenced by the number and style of template engines for PHP) - OR - skip everything and simply output directly. This does not make PHP bad at all. This is part of what makes PHP good.
Do you mean bytecode caching (e.g. accelerators), or output caching?
If the first, then I do not think it is important to me. Accelerators are free and very easy to fasten. We could argue about why they are not part of the language, but in the end, I do not think this is so important.
If you are talking about output caching, then there’s nothing to even talk about. Any web project with significant workloads needs caching. PHP has nothing to do with it.
In general, I think you consider PHP a “bad” language in a very academic sense. And people using PHP code “to get things done” on it.
Personally, I completely agree with the responder and I think that all PHP haters should familiarize themselves with the following.
PHP has an inconsistent naming of system and library functions. Predictable naming schemes are important in any language.
This is what I love and hate at the same time. However, in essence, this statement is true. Why are some two-word functions separated by underscores and some not? Why do $ needles and $ haystack sometimes swap places? This is ridiculous. But in the end is it really that important? My auto-IDE and php.net are always at hand. So maybe this is a negative factor for PHP as a language. But it does not stop me from being an effective programmer.
PHP developers are constantly abandoning built-in functions and low-level functionality. A good example is the refusal to pass parameters to a function by reference. This has become a nightmare for everyone who uses, for example, callbacks.
Personally, I think this is not a very good point. Such changes are necessary for the evolution of the language, especially for the one used on a large scale, like PHP. PHP provides a lot of opportunities to become a bad programmer, but in the same way, it is difficult for PHP developers to eliminate stupid language constructs, such as passing a value by reference. Eliminating this opportunity has become one of the best decisions they have ever made. For a beginner, there is no simpler way to shoot yourself in the foot than using this “function."
Lack of logic in the redesign. The aforementioned “abbreviations” made it sometimes impossible to specify default values for functions. This bug was fixed in PHP 5, but they also removed the transfer of variables by reference from PHP 4!
I do not think that there is any flaw in the logic. I think that this particular change strongly affected you and "there was an unpleasant aftertaste in your mouth." Changes in the language often become known months or even years before their implementation. To go from 4 to 5, there is a migration guide that describes all the differences. Passing parameters by reference was a terrible trait that did not give the developer any advantages that could not be achieved in other ways.
Poor implementation of namespace (actually from none at all). And now, when they appeared, what will be used as a separator? Backlash! A character that is commonly used for escaping, even in PHP!
I have mixed feelings about this. Part of me thinks, “what's the difference, because the escape character does not make sense outside the line”, and part of me thinks “they probably could have come up with something better”. But could they? I don't know, I'm not a Zend developer. However, the fact that we have no namespaces before 5.3 is a terrible omission.
Excessive use of type conversion leads to errors. I have no problem converting, say, float to int and vice versa. But PHP (when I last checked) will gladly try to convert the array to an integer.
I consider it normal to disagree with how PHP does this, but I do not agree that this makes the language "bad."
Poor recursion performance. Recursion is a fundamentally important tool for any language, it can make complex algorithms much easier. Poor support for this is simply unforgivable.
PHP is a DSL for the web. I worked closely with him for 8 years and used recursion on the strength of 4 or 5 times, usually to bypass directories or XML. This is not the approach often needed for web development. I do not condone low productivity, but this is a much more academic issue than productivity. If you really need fast recursion, PHP is not your choice.
Functions are case insensitive. I have no idea what they were thinking at the moment when they did it. A programming language is a way to define behavior for both a computer and a programmer, without ambiguity. Case insensitivity introduces many ambiguities.
I 100% agree with that.
PHP encourages (practically requires) mixing logic and presentation. Yes, you can write code so that it doesn’t, but it really makes it easier to write the wrong (from a design point of view) code.
How wonderful - people complain about a language that allows them to use any output system (this is eloquently evidenced by the number and style of template engines for PHP) - OR - skip everything and simply output directly. This does not make PHP bad at all. This is part of what makes PHP good.
PHP performance is terrible without caching. Tell me, does anyone sell a commercial caching product for PHP? Oh yes, the PHP developers themselves do it.
Do you mean bytecode caching (e.g. accelerators), or output caching?
If the first, then I do not think it is important to me. Accelerators are free and very easy to fasten. We could argue about why they are not part of the language, but in the end, I do not think this is so important.
If you are talking about output caching, then there’s nothing to even talk about. Any web project with significant workloads needs caching. PHP has nothing to do with it.
In general, I think you consider PHP a “bad” language in a very academic sense. And people using PHP code “to get things done” on it.