Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are java and php?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are java and php". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Java is a general object-oriented programming language designed to generate code that can use the same code anywhere; it supports both the server side and the client side. PHP, namely "hypertext preprocessor", is a general open source, object-oriented, interpreted, architecture-independent, portable and dynamic scripting language, which is mainly suitable for the field of Web development.

Operating environment of this tutorial: windows7 system, PHP7.1&&java8 version, DELL G3 computer

What is java?

Java is a general object-oriented programming language designed to generate code that can use the same code anywhere. This programming language is class-based, object-oriented, and human-readable. It supports server-side and client-side.

Java can be compiled or interpreted. The Java compiler converts the source code to bytecode, and the java interpreter generates machine code, which is executed directly by the machine running the java program. It is reliable, distributed and portable. It can be used to develop stand-alone or Web-based applications.

Java has the characteristics of simplicity, object-oriented, distributed, robust, security, platform independence and portability, multithreading, dynamic and so on. Java can write desktop applications, Web applications, distributed systems, embedded system applications and so on.

What is php?

PHP (foreign name: PHP: Hypertext Preprocessor, Chinese name: "hypertext preprocessor") is a general open source, simple, object-oriented, interpreted, robust, secure, high-performance, architecture-independent, portable, dynamic scripting language.

PHP is a scripting language executed on the server side, which is similar to C language and is a commonly used website programming language. PHP's unique syntax is a mix of C, Java, Perl, and PHP's own syntax. Conducive to learning, widely used, mainly suitable for the field of Web development.

PHP is influenced by different programming languages, such as Perl,C + +, Cjournal TCL, and Java. It is mainly developed and implemented using some features of C programming language and C + programming language. PHP supports different cross-platform operating systems, such as Windows and UNIX systems.

Most popular content management systems use PHP, which is currently considered to be the most entrenched runtime environment on the server; it provides better search engine ratings and accessibility for managed service providers.

Comparison between java and php

1. Operating mechanism:

Java code is compiled into bytecode, in the virtual machine by JIT for re-compilation into local code, it is rumored that its execution speed can be comparable to C++, after my own tests, using Java to achieve a simple Memcache protocol cache server, running under Java 1.6. compared with memcache itself, the access time ratio of the same amount of data is about 3:2, although there is a gap, but it is much better than expected. Java 1.7 has made a lot of improvements in JIT, and its performance is better than that of Java 1.6.

PHP interprets and executes the text code directly. Even with opcode caching technology, there is still an insurmountable performance gap. PHP's opcode is similar to java's class bytecode and is still interpreted and executed.

2. Deal with concurrency:

Java adopts a single-process and multi-threaded approach in concurrent processing, web applications will start with the startup of web server, and requests from web browsers will be assigned to idle threads in the thread pool, that is, when requests arrive, the process is ready, the thread is ready, and all Java has to do is business logic processing.

PHP takes a multi-process approach in concurrent processing. There is no physical concept of web application in web server. Each request is equivalent to an independent application, and the process starts with the arrival of the request and dies with the end of the request. In Fast CGI environment, there is a process pool technology similar to thread pool, which is of great help to improve performance. However, on the one hand, web server and Fast cgi still need to communicate through socket, resulting in a certain amount of IO loss, on the other hand, it is difficult to communicate between processes in the process pool, so it is still unable to compare with Java in concurrent processing.

3. Database application:

Java can use database connection pool technology to save the time loss caused by the database connection process.

PHP does not have this benefit because of the second one above.

Java has JDBC,PHP and PDO on the database interface, and these two are very similar. However, Java has a lot of ORM technology frameworks (such as Hibernate) that make database operation extremely simple, and the way PHP operates determines that it is off-limits to ORM (of course, you can also do ORM, but how much you can do is determined by how much you tolerate the performance loss caused by ORM).

The specific reason is that php cannot save global variables. Although there is a static variable in the php class, it will be deleted from memory after a http request, but the static variable of java can always be stored in memory. In this way, php cannot use the "pool" technology because the data in the pool cannot be saved.

4. Caching technology

Java is a single process, and many caches can be done directly in Java's heap without the help of external tools. Of course, there are good caching frameworks, such as Ehcache, because there is no network IO, so the performance is very high.

PHP multi-process single-threading determines that it can only rely on external cache servers, such as Memcache.

5. Hot deployment

Java's hot deployment ability is very weak, if you want to repair a BUG without stopping service is very difficult to do.

PHP natural hot deployment.

6. Development cost

A good Java programmer needs more knowledge, a longer development and debugging cycle, and a better web server is free.

PHP is free and web server is free.

7. Security

It depends on how you define security. If it's code security, java class decompilation is easy, which is pretty much the same.

Java has a security configuration mechanism to ensure that some "illegal operations" cannot be performed, which means that PHP is weak.

However, Java can easily cause the whole application to go down because of one BUG, and PHP is much more secure.

In fact, there are many benefits of Java, but only the last three can allow decision makers to choose PHP instead of Java.

That's all for "what are java and php". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report