Brief discussion on c++/java/c# operation mechanism and execution efficiency

Source: Internet
Author: User

It is estimated that a lot of students are c++/java/c# these three popular language operation mechanism and execution efficiency has more or less confusion, oneself also has, but after the previous study, understood three in these two aspects difference, on nonsense not to say, enter the subject bar.

Operation Mechanism 1, java-compiled and interpreted language a Java file, first compiled by the Java Compiler (JAVAC) into a class (bytecode file) file, and then by the Java Virtual Machine (JVM) to explain. Different operating systems can be interpreted and run as long as the Jdk,java files are installed for different platforms. Java is a compile-and-interpret language.
The main reason that the bytecode file (class) can be interpreted by the Java Virtual Machine (JVM) is that the content contained in the bytecode file (class) is a highly optimized instruction that can be interpreted by the Java Virtual Machine (JVM).
       Java files need to be compiled once to explain the operation on different operating systems, that is to say, one compilation runs everywhere, which is why Java can cross the platform.         2, c++-compiled language        C + + does not have the concept of virtual machines, which means C + + Once compiled, it is a compiled language that is much faster than Java, and after C + + is compiled, the machine code (binaries) can be run directly on the operating system.         3, c#-compiled and re-compiled language        C # with the same, there are virtual machines, But his virtual machine is the CLR (the common language runtime). A C # file, first compiled by the C # compiler into a low-level intermediate-language IL, is then compiled into machine code by the C # virtual machine, which is the common language runtime (CLR), which is then executed by the Cup. So C # execution has to be compiled two times.        implementation Efficiency       1, speed of Operation         In this respect, C + + is the fastest. Because C + + compiled into machine code can be run directly, but Java compiled after the JVM needs to explain, C # compiled by the CLR will need to be compiled two times.      2, compiling efficiency      from this aspect, C + + compiled machine code is not common to every operating system, if you switch to other operating systems need to compile again. Similarly, C # passes two compiled machine code. So this time the Java JVM Advantage is reflected, Java bytecode files run everywhere, another operating system still do not need to compile again. So, from the compilation efficiency, Java is the highest.     3, security considerations      from a security perspective, C # is the most secure of these languages, and it defines the relevant security mechanisms to ensure the security of the system well. &nbsP; Personal summary: younger brother summarized as follows:     C + + does not guarantee a certain efficiency higher than Java and C #, just like assembly language does not guarantee high efficiency over C. But they all provide a more efficient opportunity, first of all you have to be high enough to write more efficient programs, otherwise, even if you use C++/C or even assembly, it is possible to generate a low-efficiency program. Second, for C + + also depends on the compiler you use to write the level of high and low, see you compile with what kind of optimization. In other words, what language is used for development is far from being a factor of high execution efficiency, and in most cases, execution efficiency is a non-critical factor in the very back line.

Talking about c++/java/c# operation mechanism and execution efficiency

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.