Home  >  Article  >  Backend Development  >  0 Basics of learning php or java

0 Basics of learning php or java

王林
王林Original
2019-10-09 11:59:071960browse

0 Basics of learning php or java

A simple comparison between PHP and Java

The e-commerce software on the market can basically be divided into two camps, namely the PHP camp and the Java camp. However, for users who have not been exposed to e-commerce for a long time, they often see only their appearances and obvious price differences, but it is difficult to see the actual differences between them.

In fact, the efficient development and high-quality features of PHP MySQL have made Java, which is popular on university campuses, increasingly embarrassing. As for PHP, why did MySQL come from behind and take the lead in the course of history? Why does e-commerce based on Java architecture have a bleak future in addition to high development costs? First of all, you must understand the difference between PHP and Java.

1. Origin

Java was originally designed to develop a distributed code system for home consumer electronics products; PHP was born for Internet applications.

2. Comparison of the technical architecture of the system

Layering is a way to effectively organize the system. The idea of ​​​​divide and conquer is a very important idea in the computer field. Under the guidance of good layering ideas, "high cohesion and low coupling" can be achieved, and specific problems can be separated, making it easier to control, extend, and allocate resources.

Since PHP5 version, PHP has also made a qualitative leap in system architecture. ShopNC is developed using PHP language, which can perfectly realize multi-layer architecture distribution. Using the MVC design pattern, e-commerce software can have a more efficient and reasonable system architecture. This makes the system's scalability and demand adaptability comparable to e-commerce software systems written in Java.

Gutmans published an article the year before last, which also elaborated on the comparison between multi-threading (JVM) and multi-process (LAMP) in a multi-core environment. Among them, it is mentioned that multi-core systems are very suitable for the multi-process approach of the LAMP architecture. As the chip industry now focuses on multi-core rather than hyper-threading technology, the advantages of a multi-threaded environment like the JVM will not be fully utilized on today's hardware. The multi-process approach will provide more stability and reliability. In this round, PHP was victorious.

3. Database access comparison

PHP can be compiled into functions that connect to many databases. You will write your own peripheral functions to access the database indirectly. In this way, when the database used is changed, the coding can be easily modified to adapt to such changes. At the same time, current PHP provides a unified database interface PDO. Access to different databases such as Oracle, MySQL, SQL2000, etc. can be completed through the bridge without considering the database interface issues.

At the same time, in order to better support the MYSQL database, PHP also launched the MySQLi database connection, which is more efficient and secure. Java accesses the database through JDBC and accesses the database through database drivers provided by different database vendors. There is no special targeted optimization. If the developed web application is also transferred from MYSQL data to ORACLE data, PHP uses the PDO interface, and there is almost no need to make program modifications (ShopNC has already developed a self-developed encapsulated database layer, which can already complete the processing of multiple data). kind of database support, even without PDO).

Java development requires certain changes to be implemented. The difference in database access methods has established the gap between e-commerce software developed by PHP and e-commerce software developed by Java. Java is the traditional generation, but PHP is the result of the development of new technologies. PHP can not only accommodate all things Moreover, the speed has been steadily improved, and the efficiency is much more powerful than Java. This round, Java is slightly less impressive.

4. Security comparison

Open source is the biggest advantage of security, and LIUNX is a very successful proof. The PHP development program can be easily modified after others get the code. Programs developed in Java cannot see the complete source code and can only see some compiled class files. Therefore, many hidden dangers of the underlying architecture cannot be predicted in advance. Once a catastrophic error occurs, the consequences will be severe. serious.

If you want to encrypt PHP code, you can also use Zend's authoritative product zend guard for encryption to ensure the intellectual property rights of the product. If we have to compare PHP and Java in terms of security, we can only say that they are about the same. If there is a gap, it is also determined by the level of the development programmers. This round, the two are still evenly matched.

5. Foresight and expandability in the direction of Internet applications

On the whole, PHP is suitable for Internet applications, while the Java language was not designed at the beginning. It is not centered on WEB, but on general services. PHP can make the most of Internet applications, and Java is catering to the needs of WEB applications through standard or non-standard frameworks.

Why is PHP suitable for Internet applications?

First of all, PHP can adopt distributed deployment for large system loads. Separate the database, application logic layer, and presentation logic layer from each other, and separate the same layers based on traffic. PHP does an excellent job in this regard.

Secondly, PHP provides numerous database interfaces and unified interfaces. It does not take a lot of effort to unify data from multiple different databases. Java can also obtain scale support through Class and EJB, and structural support through EJB/CORBA and Application Servers from many vendors. In terms of communicating with existing Java or .NET applications, PHP can communicate through existing API interfaces. As for the data used in data communication, it is nothing more than XML, JSON, etc.

If PHP is compared to the best performance award on the Internet, it has the ability to stand alone. Then Java should win the award for the least innovation, just like the European medieval warriors, with only heavy frameworks and cumbersome efficiency. No wonder even SUN back then also supported JRuby and Jython in its J2EE solution. IBM Websphere realized that J2EE was not suitable for WEB and started the Project Zero project. The results of it? The chief architect of Project Zero also reluctantly admitted publicly that "Java can now be considered just a system language and not suitable for building Web applications."

In fact, Java has been deeply rooted in enterprise-level E-ization and key business applications. However, in Web applications, the market share of the Java language has dropped sharply, and the decline is fully apparent. So in this round, Java lost speechlessly.

6. Degree of productization

When developing in Java, almost no programmer will start from the bottom, because they are all encapsulated classes. This is actually an important reason why it is difficult to productize Java. Because almost all programmers can do relatively shallow application development.

As far as Java classes are concerned, when put on the Internet, there is only one thing that can be described as heavy. The only cross-platform superiority that Java has always claimed is actually a kind of propaganda for beginner programmers. For senior programmers, it is a joke and a piece of cake. Senior developers who have experienced many large projects know that at the beginning of development, the platform on which the program needs to run is determined. The larger the project, the more certain it is, and platform transplantation will not be easily considered. Even if new services need to be set up on other platforms, additional items will be developed on the new platform, and the connection with existing products can also be solved through Webservice. And the database doesn't matter. I don’t think anyone will use ACCESS to develop large-scale commercial programs!

As most business applications including CRM, ERP, reports, document management, etc. have also turned to the Web, looking around, there are a dazzling array of PHP products. In terms of Internet applications, it can be said responsibly that, The coverage rate is above 99%. Although the quality of many products varies, there are some representative products in each direction and field. Examples include WordPress, Drupal, mediaWiki, osCommerce, SugarCRM, Discuz, QeePHP, ShopNC, etc.

The degree of productization is an important data that directly supports the degree of industrialization. Tools that cannot be industrialized are actually very sad in themselves. In this round, Java lost completely.

7. Comparison of development and subsequent maintenance costs

Since PHP is stronger than Java in many aspects of Internet applications, why are e-commerce products developed by Java different from PHP products? What about competition? This is because the Java camp generally takes the government line, while the PHP camp takes the national line. Java relies on the words and deeds of university teachers to roar in the Internet world, while PHP relies on its own quality to win the hearts of the people, so it is praised all the way.

The price of software is largely linked to its own cost and functionality. PHP has a low entry barrier, but becoming a master in any aspect is one of the best. The vast majority of programmers who have learned C can easily transform into PHP programmers, which makes PHP programmers as popular as national sports. There are also many experts, and high-quality PHP software products are emerging in endlessly.

In terms of server cost, PHP’s most classic combination is PHP MySQL Apache, and Java is often combined with MySQL Tomcat, JBoss and other software. All software is open source and free, so the investment on the server side is not high.

The learning cost of Java programmers is several times that of PHP. The reason is also very clear. Java itself is not specifically used for WEB development. Therefore, the cost of developing e-commerce in Java is much higher than that of similar software products developed in PHP. However, precisely because the cost of Java development is high, it often takes N times more time and economic cost to develop the same product to achieve the same effect than PHP development. This directly causes a huge waste of time and cost. In the last round, Java lost completely in the WEB battle.

Through the above data, readers can also clearly realize that purchasing Java-based e-commerce products will bring you much economic costs and precious time in the subsequent maintenance period. Business opportunities are fleeting. If business operations always have to wait for a long time for technology to be realized, then I am afraid that the day lily will be gone.
Don’t be afraid of not knowing the goods, but be afraid of comparing goods. Products developed in PHP are widely used and have a good reputation, but products developed in Java are difficult to scale, which directly leads to fewer products and more project types. It is precisely because the overall performance of products developed for PHP has been tested and improved by thousands of users. Java is far from it, so it is not surprising that Java can only take the government route and use the price gap to balance the mentality of the purchaser.

Summary:

PHP is the most powerful promoter of e-commerce software development, and it will inevitably become the general trend. It is irreversible and cannot be questioned. . As programmers, whether it is PHP or Java, the issue of height is actually the same for us. The war at this level is actually a matter between the major manufacturers and has nothing to do with us. But for example, the WEB aspect. I still want to cheer for my camp!

Recommended tutorial: PHP video tutorial

The above is the detailed content of 0 Basics of learning php or java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn