I have been doing PHP development for a year, but because there is no active in-depth to contact (or learn) other languages, it is not clear that PHP relative Java, Ruby, Go, Python and other development language has any shortcomings, so want to ask you.
PS: Please use PHP 5.0 or above as the basis to answer questions, those too old version of the shortcomings do not come out to say.
===============================================================
Not to black PHP, but I think each language must have advantages and disadvantages, as a PHP developer, it is necessary to understand the shortcomings of PHP, know the advantages and disadvantages of each language in order to know the language in what scenario is suitable for use, in what scenario is not suitable for use, that's all.
Reply content:
I have been doing PHP development for a year, but because there is no active in-depth to contact (or learn) other languages, it is not clear that PHP relative Java, Ruby, Go, Python and other development language has any shortcomings, so want to ask you.
PS: Please use PHP 5.0 or above as the basis to answer questions, those too old version of the shortcomings do not come out to say.
===============================================================
Not to black PHP, but I think each language must have advantages and disadvantages, as a PHP developer, it is necessary to understand the shortcomings of PHP, know the advantages and disadvantages of each language in order to know the language in what scenario is suitable for use, in what scenario is not suitable for use, that's all.
Operating modes under PHP-FPM and mod_php (Apache):
It is said that every time you request PHP to execute a framework involved in the PHP file. You can turn on zendopcache and cache the opcode of the PHP files involved in the memory. Even if Zendopcache is not turned on, the operating system caches the PHP files into memory. The disk is not accessed every time the request is requested.
Some people say that PHP does not implement a database connection pool, each request to establish a database connection. You can then open a persistent connection so that each PHP worker process (PHP-FPM/HTTPD) maintains a connection to the database so that different requests can share a database connection, and it is important to note that The number of PHP processes is not greater than the maximum number of MySQL connections (default 151). In addition, there is no need to worry about MySQL's Wait_timeout 8-hour timeout problem, because the script executes new mysqli () and if the persistent connection times out, the persistent connection is re-established, otherwise the existing persistent connection is reused .
Some people say that PHP cannot cache data in memory, such as counters that cannot be saved to memory. You can then save the data to the MySQL memory table, or memcached and Redis in these k/v memory databases. In fact, Brother Bird has implemented a k/v cache system within the PHP process. , is YAC.
Some people say that PHP's multi-process architecture occupies a lot of memory, assuming that a process consumes 40MB of memory, open 100 processes also consumes 4GB of memory, and PHP-FPM default only open 5.
PHP This can be considered as a fastcgi Web running mode is very robust, almost no problem caused by the script of the service process crashes, almost no memory leaks, modify the code immediately effective, greatly facilitates the development and operation of the dimension, and precisely because of this, PHP can operate extensively in a hostile virtual host environment.
Even if there is no swoole, PHP under the CLI can also write daemon daemon, the network application Workerman is a case, using the following PECL extensions:
PCNTL: Process creation, signal control, timer, process status monitoring
POSIX: Daemon, user Group control
SYSVSHM: Shared memory, interprocess communication
SYSVMSG: Message Queuing, interprocess communication
Libevent: Allow PHP to use advanced event handling mechanisms such as System Epoll/kqueue
Proctitle: Changing the name of a process
Refer to PHP Core Group development member laruence on the answer:
In fact, I am relatively refusing to participate in this discussion, but think I never seem to have systematically elaborated on this issue of the view, today even if an exception.
First of all, PHP sucks? I don't really know who it is, or the people who came to this conclusion, or would you please tell me where PHP sucks? Of course, I have seen a lot of PHP failure design, such as the function name confusion, such as has been black performance poor. If that's why you say PHP sucks, then I'll refute it.
Function name confusion, this has a certain historical reasons, PHP in the process of version iteration is the first guarantee of compatibility, some old functions, in that long time, in that community no one realized that the problem of the era, has been added to PHP internal, we can not simply rename, which will cause code incompatibility, So this is the burden that we can't abandon.
But personally, I don't think the function name is messy (first of all, I'm talking about a handful, and the whole development team is going to be very concerned about the new naming of the functions, or the other consistency) is a big problem, like the various Linux distributions of the various libraries, you use which type of variable name, Would you rather not use him because you don't like the function of a class library? After you use, help you solve the problem free of charge, you save yourself the trouble of writing code, you in turn because the Human library author function name chaos, scold a rotten! Is it a little bit unkind?
As for performance, we have been working to improve PHP performance, although in the vast majority of cases, the performance of the bottleneck is not the language itself (IO, code quality), but we have been committed to do this thing, so that phper can transparently enjoy the performance of the promotion, The birth of PHP5 to PHP5.6 already has several times performance gains, not to mention the recent PHP7. If PHP previously poor performance, no problem, but in the future, with such a group of excellent contributors to improve performance for PHP, if you still close your eyes every day to say that PHP performance rotten, that is a little less objective.
For the future, PHP has a thriving community, active development groups, a large number of open source projects to support, you can do any project, you will find the right class library, the system to help you quickly complete the task, and with the performance of the upgrade. You can quickly complete the project with a small cost and quickly validate the product concept. Is this bad for millions of entrepreneurs?
Of course, not kind of the next, there are some people are single-charge is for IQ superiority, or the butt of the brain to promote some of their own things and malicious attack PHP. For example, they say the entry threshold for PHP is low (90% of these people may think that the more complicated the language, the better it is to learn), rotten. Say PHP does not support multithreading (90% of these people do not know the multithreading model and IO multiplexing model), rotten. Say PHP does not support async (90% of these people, Don't know what async stands for), rotten. PHP is a 99% language (these people are looking for IQ superiority), rotten. Often I see this kind of argument, I really helpless, because you have no way to make a fool of people become clever.
We must strive to recognize these people, for this part of the people, we can not ignore (but sometimes, these people are in front of you every day, but also very helpless). Give them some opportunity to find superiority, life has already been so hard, why deprive others to find a little consolation of the poor opportunity?
And why did PHP fire up? Because it is a good tool to help people solve problems efficiently and quickly to realize their ideas, what reason is not to be used extensively?
Finally, I really hope that the domestic community less language and tools of contention, more benign technical discussion. Every language is a very good existence, respect for each language to bring us the value of the value to society. What we have to do is to choose the right language and tools in the right place (I am a multi-lingual user, and C and PHP do not have to say, Lua, Js, Perl, Go, etc., I will use the most appropriate tool to solve my problem, you can not write in the browser to go it?), The benefits of combining each tool are what we use. Rather than being fanatical about the non-self as pagans.
Hope that the future of the language of the struggle is only as a joke, for leisure entertainment and use.
Thanks
Here's the question: since PHP is so rotten, how does it get hot?
Previously there is no memory of the process, can not directly write Deamon of the various programs ....
Until the advent of swoole
Why are so many people spitting up PHP didn't say why?
http://segmentfault.com/q/1010000002470016/a-1020000002470259
What others say is always what others say. I recommend that you learn the difference and the pros and cons of each one-month study.
I think PHP has some advantages over the disadvantages.
A few professional PHP programmers, is the biggest drawback of PHP.
It seems like a special black PHP sticker.
The advantage is professional, the disadvantage is also professional, and the same from the web2.0 era started JavaScript, PHP is always intended to hold the web development of an acre of land, and JavaScript has evolved from the front to the backend
There are always people who struggle with words. Is language so important? It's OK to solve the problem. Don't dwell on the exact language. Only some languages may be useful in a certain field.