Since the question that I linked was deleted, I put it here:
Question
I made a compromise on another topic, calling PHP a terrible language, and it went down - voted like crazy. There are apparently a lot of people who love PHP.
So I'm truly curious. What am I missing? What makes PHP a good language?
Here are my reasons for not liking:
PHP has inconsistent naming of built-in and library functions. Predictable name patterns are important for any design.
PHP has inconsistent ordering of built-in function parameters, for example array_map vs. array_filter, which is annoying in simple cases and causes all kinds of unexpected behavior or worse.
PHP developers constantly condemn built-in functions and lower-level functions. A good example is that they are deprecated for omissions for functions. This created a nightmare for those who make, say, the callbacks function.
Lack of consideration during the redesign. The aforementioned deviation precluded the ability in many cases to provide default keyword values ​​for functions. They fixed it in PHP 5, but they refused to pass by reference in PHP 4!
Poor execution of namespaces (previously there were no namespaces). Now that there are namespaces, what do we use as a dereference symbol? Backslash! A character used universally for escaping, even in PHP!
Too wide an implicit type conversion leads to errors. I have no problem with implicit conversions, say, floating point to integer or vice versa. But PHP (the last time I checked) will happily try to magically convert an array to an integer.
Poor recursion performance. Recursion is a fundamentally important tool for writing in any language; it can make complex algorithms a lot easier. Poor support is unforgivable.
Functions are case insensitive. I have no idea what they think about it. A programming language is a way to define behavior for both the computer and the code reader without ambiguity. Case insensitivity introduces more ambiguity.
PHP encourages (practically requires) the interaction of processing with presentation. Yes, you can write PHP that doesn't, but it's actually easier to write code in the wrong way (in terms of sound design).
PHP performance is terrible without caching. Does anyone sell a commercial caching product for PHP? Oh look, PHP designers do.
Worst of all, PHP convinces people that building web applications is easy. And that really makes most of the effort much easier. But the fact is, creating a web application that is safe and effective is a very difficult task.
After making sure that many are involved in programming, PHP taught a whole subset of programmers bad habits and bad design. This gave them access to opportunities that they lack for safe use. This led to the PHP reputation being unsafe.
(However, I readily admit that PHP is no more or less secure than any other web programming language.)
What am I missing in PHP? I see an organically grown, poorly managed language mess that spawns poor programmers.
So convince me otherwise!
Best answer
I'll take a hit by responding to each of your markers
PHP has an inconsistent name for built-in and library functions. Predictable naming patterns are important in any design.
I love and hate this topic. Because inherently this problem is true. Why is the bi-word function shared with underscore and some not? Why do needle and senate parameters sometimes replace positions in the argument signature? That's funny. But in the end ... does it really matter? My intellisense and php.net IDE is just a browser browser, this is just not a big deal. Is this negative for PHP as a language? Yes. Does this interfere with my ability to be an effective programmer? No.
PHP developers constantly discount the built-in functions and lower level. Good example, when they are deprecated pass-by-reference for functions. This has created a nightmare for anyone who does, say, callback functions.
Personally, I think this is not very good. Aversion is necessary for the evolution of a language, especially one that has as much as PHP. PHP gets a lot of flacks to “simplify working with a bad programmer,” but at the same time, the PHP group also has problems when they try to remove silly constructs from the language, such as call forwarding -Help. Eliminating call forwarding over time was one of the best steps they have ever taken. There was no easier way for a novice developer to shoot in the foot than with this “feature.”
Lack of consideration during the redesign. The above exception eliminated the ability in many cases to provide default keyword values ​​for functions. They fixed it in PHP 5, but they are deprecated for forwarding in PHP 4!
I don’t think there is a general lack of attention at all, I think you just got stung by this particular change and stayed with a sour taste in your mouth. Language changes are often known for months, if not years earlier. A migration guide was provided for the transition from 4 to 5, and the differences in the version are indicated in the manual. Call time redirection was a terrible "function" and did not give the developer any expressive power that they could not get by other means. I'm glad he left (along with other shit, like magical quotes)
Poor execution of namespaces (previously there were no namespaces). Now, what are the namespaces that we use as a dereference symbol? Backslash! The character used is universal for escaping, even in PHP!
I have mixed feelings about this. Part of me thinks, “who cares, character escape doesn't matter outside the line anyway,” and part of me thinks “for sure they could use something better.” But could they? I do not know, I am not a developer for the Zend parser. Is this a huge oversight that before 5.3 PHP never had a namespace at all? Yes, absolutely.
Too wide an implicit type conversion leads to errors. I have no problem with implicit conversions, like float to integer or vice versa. But PHP (the last one I tested) will happily magically convert an array to an integer.
I think I don’t agree with how PHP does it, but I don’t agree that it makes the language “bad”. But ask me how much I want to sit on this topic and argue about weak versus strong typing. (PS I don’t do this at all). For the record: PHP will throw an E_WARNING level error when the type of the argument matters and cannot be resolved by force.
Poor recursion performance. Recursion is a fundamentally important tool for recording in any language; it can make complex algorithms a lot easier. Poor support is unforgivable.
PHP is the DSL for the web. I have been doing this full time for 8 years and may have used recursion 4 or 5 times, usually for some type of annoying directory or XML traversal. This is simply not the template that is often needed for web development. I do not condone slow performance, but this is an academic problem far more than a production problem. If you need really powerful recursive performance, PHP is no longer the language for you.
Functions are case insensitive. I have no idea what they were thinking about this one. A programming language is a way to specify behavior for both a computer and a code reader without ambiguity. Case insensitivity introduces more ambiguity.
I completely agree with this 100%.
PHP encourages (practically requires) connection processing with presentation. Yes, you can write PHP this is not so, but it’s actually easier to write the code in the wrong way (in terms of sound design).
* Hmmm, this topic sounds desperately familiar ...
But seriously, I find it wonderful that people will complain about a language that will absolutely 100% allow you to implement any output system that you want (only volumes and style of PHP templating systems speak about it) - OR - skip all that overhead and just output directly. This does not make PHP bad. This is part of what makes PHP good.
PHP performance is terrible without caching. Does anyone sell commercial product caching for PHP? Oh look, PHP designers do.
Do you mean bytecode caching (like an accelerator) or output caching?
If the first, then I really don't know how much I care about this topic. Accelerators are free and easy to start. We can argue about why it is not part of the language, but in the end, I don’t think it matters much.
If you're talking about output caching, I don't know what to tell you. ANY web project with significant traffic caching (e.g. seed podcast # 27). This is not a PHP specific issue.
All in all, I think you think PHP is a “bad” language in a very academic way. And in your previous post, you were probably rejected by people like me who use PHP to "do the job."
Second best answer
All your criticisms (and some others) are valid. You are allowed to and even expect to hate PHP.
But, again, it has some advantages:
- All-local
- Fast (especially using operation operations caches)
- Huge community (and great documentation)
- Work
Finally, you can overcome many, if not all, of the shortcomings by writing good code that you can write in any other language. You can write reliable, safe and good code, inflated in PHP, which will run faster many times and will be easier to place and scale than many alternatives.
Third Rating>
What am I missing in PHP? I see an organically grown, poorly managed language mess that spawns weak programmers.
Simple The fact that poor programmers are very protective of their language .;) PHP is easy to learn, much easier than alternatives, and once you know it, it is not entirely obvious: 1) what is with PHP, 2) how are the alternatives better, and 3) how to switch to and find out one of the alternatives.
And perhaps the fact that, what alternatives do people have? ASP? This has many problems on its own, due to the inability to run on most web servers (Apache), to some ridiculous and redesigned design options on your own (web forms? ViewState? AJAX, where your asynchronous requests are intercepted and run sequentially?) Rubin on rails? Well, perhaps, besides, how many web servers support it again? At the moment, it is not quite readily available. And it’s slow. So maybe PHP's “strength” is really such that there is no good alternative. At least that is why I always avoid any web programming. PHP sucks, and I'm not too keen on any of the alternatives either.
PHP has so many fundamental problems that it’s not even funny. Due to the lack of unicode support, to many implicit type conversions that often lead to unexpected security holes, to completely mixing up the presentation and ... everything else, or to the default database module that didn't (the last time I checked) parameterized queries . We are talking about a language made for two things: database access and HTML generation, and which is terrible for both.
It’s just an unpleasant mess, a language developed by people who are not qualified or able to develop a language .;)