This article mainly from 8 aspects of PHP and Java in the Web development of the pros and cons of doing a comparative analysis, a very good article, here recommended to the small partners.
Comparing PHP and JSP two Web development technologies, the current situation is actually compared to PHP and Java Web development. Here are my comparisons on several key areas:
A language comparison
PHP is the server scripting language that interprets execution, and first of all, PHP has a simple, easy to start feature. Grammar and C language is more like, so the programmer who has learned C language can quickly become familiar with the development of PHP. Java needs to learn Java grammar and familiar with some of the core class library, understand the object-oriented program design methods. So Java is not as studious as PHP.
Java is first compiled into a bytecode. class file and then interprets execution on the Java virtual machine. Java Web Development is the most easy to think of the first is JSP (now to JSP2.0), the original Java Web development is implemented with a servlet, using a servlet to develop requires programmers in Java source files embedded in a large number of HTML code. So then there is the jsp,jsp can be easily embedded in the HTML file, in fact, JSP files on the server when the implementation of the first will be the application server into a servlet, and then compiled execution. JSP can produce powerful functionality through the support of servlet and JavaBean. JavaBean is a reusable, cross-platform software component. The use of JavaBean can facilitate the separation of Java code and HTML, and can enhance the function of the system and the reusability of software.
Java Web Development is a specification of Sun's definition of EE. And it includes all aspects of Java Web development, such as JSP, Servlet, JDBC, JNDI, JAVABEAN, EJB, and so on. Java EE is particularly suitable for large enterprise-class applications.
Second, database access comparison
Java accesses the database through JDBC and facilitates access to the database through database drivers provided by different database vendors. The interface to access the database is more uniform.
PHP for different databases using different database access interface, so the database access code is not universal. For example, using Java-developed Web applications to go from MySQL to Oracle databases requires little modification. and PHP needs to do a lot of modification work.
Comparison of system Design architecture
Using Java Web Development technology, we need to use object-oriented system design method, and PHP is a process-oriented development method. So in the early development of Java to do a lot of system analysis and design work.
Iv. Cross-platform nature
Both Java and PHP have good cross-platform features. Almost all of them can run on different operating systems, such as Linux or Windows, without making any changes.
V. Comparison of development costs
PHP's most classic combination is: PHP + MySQL + Apache. Very suitable for the development of small and medium-sized Web applications, the speed of development is relatively fast. And all the software is open source free, can reduce the input.
Java Web application servers are free tomcat, JBoss, and so on, if the need for better commercial services are: Web sphere and Web logic.
Comparison of distributed multi-tier architectures
PHP can only achieve a simple distributed two-tier or three-tier architecture, and Java in this respect is more powerful, you can achieve a multi-tiered network architecture. The database layer (persistence layer), the application (business) logic layer, the presentation logic layer are separated from each other, and now different layers already have some mature development framework support. For example, struts is using Java Web Development technology to implement the MVC design pattern, while the business logic layer also has the spring framework, the database persistence layer has hibernate framework. These frameworks make it easy for developers to efficiently, rationally and scientifically structure multi-tier business applications.
Here is a brief summary of struts, which is essentially an MVC (Model, View, controler) framework that is implemented on the basis of JSP Model2. JSP Model2 Architecture is a way of combining JSP and servlet to provide dynamic content. In the struts framework, the model consists of JavaBean or EJB components that implement the business logic, and the controller is implemented by the servlet, and the view consists of a set of JSP files. Struts can be used to define roles and the division of work between developers and web designers. And the more complex the project, the more obvious its advantages.
Vii. Source code Security
PHP development of the program's source code are open, others get the PHP development program can be modified.
Java development of the program, the last user to get is just some of the compiled class class, can not see the full source code, high security.
Viii. Performance Comparisons
Some experiments have been done to perform loop performance testing and access to Oracle database tests for these two languages respectively.
In the cyclic performance test, the JSP ended the 20000*20000 loop with an astonishing four seconds. The PHP test is the 2000*2000 cycle (one less order of magnitude), but it took 63 seconds respectively.
In database tests, the two 1000 times insert,update,select and delete:jsp for Oracle 8 require 13 seconds, and PHP takes 69 seconds.
To sum up, I personally think that PHP is suitable for rapid development, small and medium application systems, low development costs, able to respond to the changing needs of the rapid response. and Java is suitable for the development of large-scale application systems, the application of a broad prospect, easy maintenance system, reusable good. Also, systems with the same functionality are more expensive to develop in Java than the systems that PHP develops.
The above is the entire content of this article, I hope that we can help.