java and c ++ compare, which is more efficient?

 In recent cow brush off network, a problem is found. Do a question, if if written with c ++ language, either in time or space, the effect is better than java.

With my own knowledge, I can think of it, that is a little fur, because c ++ is a compiled language, but java is interpreted language. And what is a compiled language , what is interpreted language it ?

Compiled language: the program before execution requires a special compilation process, the program files compiled into machine language translation does not need to re-run, the direct result of using the compiler on the line. High efficiency of program execution, depending on the compiler, cross-platform poor. c, c ++, Delphi and so on.

Interpreted language: does not need compilation, when translated into machine language program runs each time we perform a translation. So efficiency is relatively low. For example, the Basic language, there is a dedicated interpreter Basic program can be executed directly, when each statement is executed only translation. Efficiency is relatively low, dependent on the interpreter, cross-platform is good. Run: first translated into an intermediate code, and then executed by an interpreter.

Interpreted and compiled explanation and description:

1. compiled language

  Compiled language refers to the all-time code is compiled, then executed.

  Advantages: speed execution; disadvantages: low development efficiency.

2. interpreted language:

  Interpreted language refers to each compiling an execution sentence.

  Advantages: development of high efficiency; disadvantages: slow speed of execution.

Note: When very large amount of code, there are tens of thousands of lines even more often, just put all the code to compile, you may need to spend a few hours of time. Thus, once the code is wrong, for compiled languages, it would need to start compiling heavy head, extremely time consuming.

  Development of low efficiency, but his execution is fast. Instead interpreted language, explain each one, on the implementation of the way, once the error can be corrected in time, continue to compile, therefore, the development of high efficiency, but slower.

The difference between compiled languages ​​and interpreted languages

Explanatory language to the translation when running a program, such as basic interpretive language, there is a special interpreter capable of performing basic program directly, when each statement is executed only translation. Such an interpreted language translation will be performed once every time, efficiency is relatively low.

Compiled and interpreted, both have their advantages and disadvantages

The former because the program fast execution, under the same conditions for low system requirements, like the development of operating systems, large-scale applications, database systems have adopted it, like C / C ++, Pascal / Object Pascal (Delphi), etc. are compiled language, and some web scripts, server script and assist in developing such an interface speed of less demanding, there are certain requirements for compatibility between different systems platforms procedure is usually interpreted language, such as Java, JavaScript, VBScript, Perl, Python, Ruby, MATLAB, and so on.  

Compiled language is better, good cross-platform interpreted language

Compiled languages such as c language: After developing procedures c language required by a compiler the compiled into machine language (i.e., a computer to identify a binary file because of different computer's operating system to identify the binary file is different), so that c after the transplant language program, to be recompiled. (Such as windows compiled ext file, linux compiled erp file).  [2] 
An interpreted language, such as language java, java program first by the compiler compiled into class files, if you are running on windows platform, be explained by the java virtual machine (VM) on the windows platform. If you are running on a linux platform, it is interpreted by the java virtual machine on a linux platform. So cross-platform, provided that the platform must be matched to the java virtual machine. If there is no java virtual machine, it can not be cross-platform.

Guess you like

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