Why java run the same code is longer than c ++?

The general framework of this blog post is a reference to the original blog post
There organize some of their own information, and then there are some of their own search. Answers to the more esoteric knowledge in this post.
. 1) is a java interpreted language, related classes class loader path from the java class at runtime, and then reads the byte JVM class file, perform a corresponding operation. When the C ++ compiler to compile the program cost native machine code. Generally java program execution speed of 10-30 times slower than C ++. (after reading the class file bytes, compiled to native machine code) even with just-in-time compiling technology, speed than C ++ slow lot. 
1 supplementary explanation:
Because the JVM itself is to use C / C ++ to write, which means that you want to run Java, it is necessary to start and play a C / C ++. In other words, Java JVM compiled by the C / C ++, which is directly comparable to write C / C ++. This is not to belittle Java, sometimes C / C ++ development difficulty is great, in many cases last resort. Such as 0 and 1 may implement any operating system , but the angle is not the developer to the.

2) class java program has loaded byte from the network, and then executed, which is the cause of slow running java.

3) the program is running, the detection array java virtual machine is out of bounds, is not detected in C ++ .

In a blog post that provides links: https://blog.csdn.net/ive_lanco/article/details/81094484

4) in the Java all objects are created on the heap, no object is created in the stack, whereas some C ++ objects and variables are created in the stack of

In this blog post provides links: https://blog.csdn.net/rickiyeat/article/details/76802085

This blog, we can appreciate nature to watch, but if we are deep enough qualifications, then we can explain some

Welcome to leave a message at the bottom of my blog post.

5) java during operation detected object reference is null, null pointer exception will be thrown if all references to a null pointer, and the execution of a method

6) java runtime type checking, if the incorrect type of throw a ClassCastException.

garbage collection. 7) java lower than the C ++ programmer memory management efficiency.

8) in the java primitive data types are the same in each of the length of the operating system platform, the C ++ data types length is OS vary, so when there java execute on different operating systems a conversion process.

9) in java String is the UNICODE. when java to operate an ASCII string, is relatively lower than the C ++ efficiency number. 

10) in java It uses a dynamic link

11) mechanisms jvm itself, such as garbage collection , find and load classes, etc. There is also time consuming.

However, everything has two sides, java likely than c, c ++ slow, but the platform for us to shield a lot of machine and operating system differences, we write java code base without much consideration of machine and operating system thing itself. And has good portability . For example, you write the code in Windows java, basically only need minor modifications to run under the Linux.

Guess you like

Origin www.cnblogs.com/littleswan/p/11374290.html