Web development: Java vs. php

Source: Internet
Author: User

Compare php and JSP two Web development Technology, in the current situation is actually compared to PHP and Java Web development. Here are some of the main areas I'll compare:

I. Comparison of languages

PHP is the server scripting language that interprets execution, first PHP has a simple and easy-to-follow feature. Grammar and C are more alike, so programmers who have studied C can quickly become familiar with the development of PHP. Java needs to learn Java grammar and familiar with some core class library, and understand object-oriented program design method. So Java is not as studious as PHP.

Java is first compiled into a bytecode. class file and then interpreted for execution on the Java virtual machine. Java Web Development is the first most likely to think of the JSP (now to JSP2.0), the original Java Web development is implemented with a servlet, using the servlet to develop a programmer in the Java source files embedded in a large number of HTML code. So then came the jsp,jsp can be conveniently embedded into the HTML file, in fact, the JSP file on the server when the execution of the first application server will be converted into a servlet, and then compiled execution. JSPs can generate powerful functionality through the support of Servlets and JavaBean. JavaBean is a reusable, cross-platform software component. The use of JavaBean can easily realize the separation of Java code and HTML, which can enhance the function of the system and the reusability of the software.

Java's web development is a specification of a sun company-defined EE. It also includes all aspects of Java's web development, such as JSP, Servlet, JDBC, JNDI, JAVABEAN, EJB, and so on. The Java EE is particularly well-suited for large enterprise applications.

Second, database access comparison

Java accesses the database through JDBC and provides easy access to the database through database drives provided by different database vendors. The interface to access the database is more uniform.

PHP has different database access interfaces for different databases, so the database access code is not very versatile. For example, a Web application developed in Java requires little modification from the MySQL database to the Oracle database. and PHP needs to do a lot of modification work.

Third, the system design architecture comparison

Using Java Web Development technology, it is necessary to use the object-oriented system design method, and PHP is a process-oriented development approach. Therefore, it is necessary to do a lot of system analysis and design work in the early development of Java.

Iv. Cross-platform

Both Java and PHP have good cross-platform features. Almost all can be run on different operating systems, such as Linux or Windows, without any modifications.

V. Development cost Comparison

PHP's most classic combination is: PHP + MySQL + Apache. Ideal for developing small to medium-sized Web applications, it is faster to develop. And all the software is open source free, can reduce investment.

Java's Web application server has free tomcat, JBoss, and so on, if the need for better commercialization of services are: Web sphere and Web logic.

Six, distributed multi-layer architecture comparison

PHP can only implement a simple distributed two-tier or three-tier architecture, and Java in this area is more powerful, you can implement a multi-layered network architecture. The database layer (persistence layer), the application (business) logic layer, the presentation logic layer are separated from each other, and now the different layers have some mature development framework support. For example, struts is the use of Java Web Development technology to implement the MVC design pattern, but in the business logic layer also has spring framework, database persistence layer has hibernate and other frameworks. These frameworks enable developers to efficiently, rationally, and scientifically architect multi-layered business applications.

Here's a brief look at struts, which is essentially an MVC (Model, View, controler) framework implemented on the basis of JSP Model2. JSP Model2 Architecture is a method of combining JSP and servlet to provide dynamic content. In the struts framework, the model consists of a JavaBean or EJB component that implements the business logic, and the controller is implemented by the servlet, and the view consists of a set of JSP files. Using struts, you can define the definition of roles and the division of labor 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 is public, others get PHP development program can be modified.

Java Development Program, the last user to get is just some compiled class class, can not see the full source code, security high.

Eight, performance comparison

Some people have done experiments on these two languages to do loop performance testing and access to Oracle database testing.

In the cyclic performance test, the JSP ended the 20000*20000 loop with only an astonishing four seconds. The PHP test is a 2000*2000 loop (less than an order of magnitude), but it took 63 seconds, respectively.

In database testing, the two 1000 insert,update,select and delete:jsp of Oracle 8 were required for 13 seconds, and PHP required 69 seconds.

To sum up, I personally think that PHP is suitable for rapid development, small and medium-sized applications, low development costs, can be a rapid response to the changing needs. Java is suitable for the development of large-scale application system, the prospect of application is broad, the system is easy to maintain, reusability is better. Also, systems developed by the same function in Java are more expensive than those developed by PHP.

Web development: Java vs. php

Related Article

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.