Introduction: This is a detailed page for comparing Java and PHP in Web development. It introduces PHP, Java, PHP, web, java and PHP compare the knowledge, skills, experience, and some PHP Source Code related to Java and PHP in Web development.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 359499 'rolling = 'no'>
Comparing PHP and JSP web development technologies, the current situation is actually comparing PHP and Java Web development. The following is a comparison of several main aspects:
I. Language Comparison
PHP is the server script language for interpretation and execution. First, PHP is easy to use. Syntax andC LanguageSimilar, so I have learned the C LanguageProgramDevelopers can quickly get familiar with PHP development. Java needs to learn the Java syntax and be familiar with some core class libraries, and understand the object-oriented programming method. So Java is not as good as PHP.
Java must first be compiled into a bytecode. Class file and then interpreted and executed on the Java Virtual Machine. Java Web development is most likely to come up with JSP (now
Jsp2.0), the original Java Web development is implemented using Servlet, Servlet development requires programmers to embed a large number of HTML generation in the Java source file
. As a result, JSP emerged. jsp can be easily embedded into HTML files. In fact, when the JSP file is executed on the server, it is first converted to servlet by the application server.
And then compile and execute. JSP can generate powerful functions through Servlet and JavaBean support. JavaBean
Is a reusable, cross-platform software component. JavaCodeThe separation from HTML can enhance the functionality of the system and the reusability of software.
Java Web development is a standard defined by Sun in J2EE. In addition, J2EE includes all aspects of Java Web development, such as JSP, Servlet, JDBC, JNDI, JavaBean, and EJB. J2EE is particularly suitable for large-scale enterprise applications.
2. Database Access comparison
Java accesses the database through JDBC, and the database driver provided by different database vendors facilitates access to the database. Database access interfaces are unified.
PHP uses different database access interfaces for different databases, so the versatility of database access code is not strong. For example, only a few modifications are required to switch a web application developed in Java from a MySQL database to an Oracle database. PHP requires a lot of modification.
Iii. system design architecture comparison
Using Java Web development technology, we need to use an object-oriented system design method, while PhP still uses a process-oriented development method. Therefore, a lot of system analysis and design work is required in the early stage of Java development.
Iv. cross-platform
Both Java and PHP have good cross-platform features. Almost all of them can run on Linux, windows, and other operating systems without any modification.
V. Development Cost Comparison
The most typical PHP combination is: PHP + MySQL + Apache. It is very suitable for developing small and medium-sized Web applications with fast development speed. In addition, all software is open-source and free of charge, which can reduce investment.
Java Web application servers include free Tomcat and JBoss. If you need better commercial services, such as web sphere and Web Logic.
6. Comparison of Distributed Multi-layer architecture
PHP can only implement a simple distributed two-layer or three-layer architecture, while Java is relatively powerful in this respect, and can implement a multi-layer network architecture. Database layer (persistence layer), application (business) Environment
The logic layers are separated from each other, and different layers now have some mature development frameworks. For example, Struts uses Java Web development technology to implement the MVC design model.
The business logic layer also has the Spring framework, and the database persistence layer has the Hibernate framework. These frameworks allow developers to efficiently, reasonably, and scientifically construct multi-layer commercial applications.
The following is a brief description of struts, which is essentially in JSP
A mvc (model, view, and controler) framework based on model2. JSP model2 architecture is a kind of joint use of 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. The controller is implemented by the servlet, and the view is composed of a group of JSP
File. Struts can be used to define roles and the division of labor between developers and web designers. The more complex the project is, the more obvious its advantages are.
VII,Source codeSecurity
The source code of PHP programs is open, and others can modify them after obtaining the programs developed by PHP.
Java-developed programs, the user finally obtains only some compiled class classes, unable to see the complete source code, high security.
VIII. Performance Comparison
Some people have performed tests to test the performance of the two languages respectively and to access the Oracle database.
In the cyclic performance test, JSP ended the 20000*20000 loop in just four surprising seconds. PHP tests 2000*2000 cycles (one order of magnitude less), but it takes 63 seconds.
During database testing, the two performed 1000 insert, update, select, and delete operations on Oracle 8 respectively. It took 13 seconds for JSP and 69 seconds for PHP.
Project |
PHP |
Java |
Reusability |
Low |
High |
Development Speed |
Fast |
Slow |
Easy to maintain |
Difference |
Excellent |
Portability |
- Linux |
Windows , UNIX |
Security |
Low |
High |
Development Cost |
Low |
High |
Multi-layer architecture |
Difference |
Excellent |
Database Access |
Inconsistent Interfaces |
Unified Interfaces |
Scalability |
Difference |
Excellent |
Object-oriented |
Difference |
Excellent |
In summary, I personally think that PHP is suitable for rapid development, small and medium application systems, low development costs, and quick response to changing needs. Java is suitable for developing large-scale applications.
The system has broad application prospects and is easy to maintain and reusable. In addition, systems with the same functions developed using Java are more expensive than those developed using PHP.
Source: exam Major
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/359499.html pageno: 1.