Java and PHP compare to Web development

Source: Internet
Author: User
Tags php compare java web
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. Database Access Comparisons

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. System Design Architecture comparison

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. 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. Development Cost Comparisons

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 multilayer 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. 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. Performance Comparison

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. Summary

Project PHP JAVA
Reusable Low High
Development speed Fast Slow
Ease of maintenance Poor Excellent
Portability Excellent-linux Windows, Unix
Security Low High
Development costs Low High
Multi-tier architecture Poor Excellent
Database access Interface is not uniform Interface Unification
Scalability Poor Excellent
Object-oriented Poor Excellent

PHP is suitable for rapid development, small and medium application systems, low development costs and the ability to respond quickly to changing needs. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.