Java is a cross-platform language. what is a cross-platform language? I think the phpC language can also be developed on different platforms. what language is cross-platform? what is the difference between their cross-platform features? is java a cross-platform language? I think php C language can also be developed on different platforms. what languages is cross-platform? is there a difference in their cross-platform features? reply: Java's cross-platform is "one compilation, run everywhere ". Java does not compile the compilation code of the specified CPU type during compilation, nor is it associated with the system call of a specific operating system. Therefore, the compiled result is CPU, the operating system is irrelevant. Java compiled a bytecode that must be run on a Java virtual machine. the Java virtual machine shields the differences between different operating systems and CPUs.
After C is compiled, it specifies the compilation code of the CPU type. during the compilation process, it must be related to the system library of the specific operating system. Therefore, it cannot be implemented across platforms like Java. However, if the written C code does not directly call any system call, the code can be compiled and run on different platforms. The difference with Java is that C must be compiled on different platforms separately.
Some languages, such as JavaScript and Python, are interpreted and executed, and there is no compilation process, so they can also be cross-platform, provided that a corresponding interpreter is required, and PHP seems to be explanatory. Cross-platform languages are built on underlying facilities that are not cross-platform.
For example, the standard library of C/C ++
Java virtual machine,. NET Runtime
These are not cross-platform. In fact, it is of little significance to discuss cross-platform. The so-called cross-platform language means that the code you write can be directly applied to another operating system or even the cpu without modification.
But now almost all languages are like this ...... C/C ++, Java, C #, Python, PHP, JS, Ruby, Go ...... And so on.
Java said that it is cross-platform because, compared with C, the compiled binary file can be stored in any other
A platform with the Java Runtime Environment installed. C, the compiled items can only run on a class-one operating system, but it won't work if it is changed,
No additional running environment installation requiredHowever, you can still compile a separate copy for the specified cpu and operating system.
In addition, C #, python, php, js, and so on can all run directly on multiple platforms. But they all need
Corresponding runtime environment. It's time to show me big JavaScript!
As long as you can access the Internet, you need to use js.
When running WebView on a mobile phone, React-native is of course a relatively high force.
Game Canvas
Even single-chip microcomputer can be written, although the function is relatively weak.
PC end, there are many use electron.
Browser... Which language is the target language.
I think the significance of "cross-platform" should be only the interface.
After all, the server is almost the world of Linux. You cannot write server software for Windows.
Please believe! The UI must be javascript or its derivative language! Java cross-platform developers have the minimum cost, and one compilation runs everywhere. Some functions of C language, python, and php must use some specific functions of the operating system, and the development cost is relatively high.
In fact, many languages now have a certain degree of cross-platform capabilities, but in fact they are generally useless. java and h5 can be used across platforms at no cost, most of them have poor experience. It doesn't make much sense to do so. it is the first thing that can be done in a very good way, and then rewrite the performance-heavy module with C. Strictly speaking, no language can be used across platforms. C #, open source, Swift, and open source ...... First of all, we do not call it a cross-platform mechanism. many people may easily confuse this concept.
Therefore, the biggest feature of cross-platform languages is that machine code is not compiled and system APIs are not used.
1. do not compile the machine code, because the CPU is different in different environments, although the PC is x86, but if it is not a PC but a mobile phone, then the CPU instruction set is not x86, then your machine code will be completely discarded, it cannot be cross-platform.
2. if you do not use operating system APIs, different system APIs have different definitions, usage, and soft interrupt vectors. code that uses system APIs to create threads and processes cannot be used in general.
Java runs on a virtual machine. the compiled code is JVM running, and the logic directly runs without a CPU. as long as the hardware is installed with JVM, you do not need to worry about the CPU, similarly, he encapsulated the system API into a common JAVA library. Although the system is different, the system kernel is doing similar things and encapsulated and used everywhere, so there is no problem, in addition, QT is encapsulated and unified to achieve cross-platform or portable, but the problem is that QT is not a programming language...
However, the language itself does not represent code cross-platform. Otherwise, the PC and android will not need to write two versions of java, because many system resources need to be encapsulated in a unified manner, which requires a great deal of work, it is also easy to bring about some negative effects. this is a price, and there is no return for the price (for example, Microsoft makes a VS that supports the android system and can run on the PC, where is the return? Once done, it may also be deemed by the program developers to be "out of favor" and "meaningless". it is not a problem to make two apps. if there is an incompatible BUG between the two, no one will do this job for the benefit of mankind if there is no return, therefore, a compilation of java runs everywhere and looks beautiful. it is actually just a nonsense, but it does not prevent java from being a cross-platform language, but its work is not in place.
Another cross-platform language is called a macro language. Many of these languages do not need to be compiled. This type of language generally has limited scope of work. for example, it is specialized in web pages and specialized in databases, and flash as scripts .. For HTML, he does not compile. In the end, he is only a protocol. the purpose of this language is to describe web pages in text and implement this protocol by browser vendors, it can implement android, PC, and Apple browsers, but it recognizes HTML scripts. HTML is a cross-platform language... The same is true for other languages. to say that they are an abstract protocol, they need to execute their apps or services to run them. as long as the developers make programs according to the agreed protocol, this language is cross-platform, but the macro language has limited functional scope... It must be qt. The function of a programming language is only to describe an algorithm. if it is not for optimization or translation, it is none of my business.
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.