Here the title is to talk about the difference between PHP and Java, in fact, is a euphemism, in fact, others want to listen to PHP good or Java good!!! Thus find the sense of existence!!!
Because I am from the years of PHP development to Java development. So, most of the time, there are several colleagues asked me, you think Java is good or PHP good. Every time I answer is, different, each has its own advantages, this is the most practical answer.
Then come and think about what the difference is. Today I will be careful to summarize, PHP and Java in the end what is the difference between it.
1. PHP is write-ready.
That is, each time only one change is completed, the user immediately see the effect, and Java is much slower, the code changes to complete, to recompile, and then restart the JVM, the middle of the time is a lot of ah, and restart the JVM process will cause user response interrupted Oh.
2. php write something fast.
PHP can be said to be very agile, a need to give, as long as not consider the late performance and user volume problems, it is quite fast, and even you can not use the framework, direct writing will also be very fast, write a delete and change to check the function, may also be 30-50 lines of code to be done. And Java is much slower, first of all to think about what the framework, is basically spring, and then is the configuration of various databases, filters, Servlets, decided to use MyBatis or hibernate, and then consider the transfer between the code, and then consider the transaction ... And then constantly debugging, a change of code may be a few minutes of waiting time, imagine.
3. The surface of PHP is more clear-minded.
What is a superficial idea, is that what you see is what is really done, such as echo "Hello World", is the output Hello World, and Java is different, you may be writing response, may be written in Modelattribute, It may also be the return of the string, and then do not know how, it is displayed on the page.
4. PHP consumes less memory.
PHP is a process-processing problem, occupies a very small amount of memory, you can say that you deploy 50 projects on a machine without any problems, as long as the traffic does not come up, make it. And Java is not, Java every start a project, itself will have to run out of memory, such as in a 8g memory of the machine, generally run on 2 of projects almost.
5. Does Java have any good to say about the benefits of PHP? That's impossible.
6. Many Java components.
I personally feel that this alone has covered all the other advantages, because the number of components, means that the use of more people, the eyes of the masses are discerning. So, Java must be good, it has accumulated a lot of things, not a new language can be casually replaced. What you want to do, a good search for Java components, and probably all the features you need, especially for the most popular big data industry today, Java is more of a party. And PHP is a little powerless in this scenario.
7. Java thread pool, connection pooling, easy to asynchronous.
In fact, this is similar to the 1th, and because of the number of components, it is convenient to use the thread pool connection pool, which is absolutely necessary for high concurrency and high performance scenarios. Because Java is running the reason is multi-threaded, so do not have to initialize a lot of basic things every time, this saves too much time, so we can endure the slow process of server startup, because only once. and PHP is a multi-process, each time need to reload all the required code, it is not possible to save some common data in memory, connection pool is not good to do, asynchronous operation is a large short board.
8. Java is the logical clarity of the real sense.
Because, in Java, you can use the IDE tool to analyze to the deepest logical operation, for each field can be clearly understood, this is actually an interface and a full object of the advantages of using. PHP can not do or say that very few people to do this kind of thing, PHP is half-object-oriented semi-oriented process development, so it is normal to insert a few custom function calls in the call process, then you want to use the simple IDE to analyze the call chain is not so easy. For example, for a third-party interface, PHP is difficult to see clearly what the interface returns, unless you print it out, but it is not necessarily printed, because some of the return value of the data does not necessarily reflect. This adds a big threshold for understanding the code.
9. Java compilation is annoying, but you can find errors ahead of time.
Java compilation is really time-consuming, but if there are obvious errors, the compilation will not pass, which gives you a chance to recheck the code. and PHP will not, no matter how bad you write, will not give you a hint, and many times, often because less write a semicolon, causing you to troubleshoot for several hours.
Java Remote Call convenient, Rmi,hessian,dubbo.
In any case, remote and local calls are easy to know about, and Java's same-language calls do not use pure HTTP calls, and maintain a certain connection, which greatly improves performance. PHP also has remote calls, but it is relatively weak.
In fact, no problem is not absolutely good or bad, the existence is reasonable. It's just a different application scenario.
Let me talk about the differences between PHP and Java in web development.