Java的哪些特性允许它比同类C ++程序更快地构建? [重复]

时间:2023-01-01 17:20:38

Possible Duplicate:
Why does C++ compilation take so long?

可能重复:为什么C ++编译需要这么长时间?

I am working with two different projects of about the same size (loc). The Java build process using Ant is measured in minutes. The C++ build processing using the CMAKE tools is measured in hours.

我正在处理两个大小相同(loc)的不同项目。使用Ant的Java构建过程在几分钟内完成。使用CMAKE工具的C ++构建处理以小时为单位进行测量。

What characteristics of Java allow it to build much faster than a comparable C++ program?

Java的哪些特性允许它比同类C ++程序更快地构建?

6 个解决方案

#1


You might find this question helpful. The accepted answer doesn't emphasize a comparison to java, but you might be able to infer quite a bit about what C++ is doing that takes so long.

您可能会发现这个问题很有用。接受的答案并没有强调与java的比较,但你可能能够推断出C ++正在做什么需要这么长时间。

#2


I have to suspect that the absence of kilolines of header files is a lot to do with it.

我不得不怀疑头文件的缺少与它有很大关系。

#3


Templates are especially slow to compile.

模板编译速度特别慢。

#4


Different Optimization Strategies

不同的优化策略

Java code is typically not optimized as much as C/C++ code at compile time. This means that Java byte code is "less optimized" than "similar" native code emitted by C/C++ compilers. The JVM's Just In Time (JIT) compiler does optimizations at runtime to increase byte code performance.

在编译时,Java代码通常不像C / C ++代码那样优化。这意味着Java字节代码比C / C ++编译器发出的“类似”本机代码“更少优化”。 JVM的Just In Time(JIT)编译器在运行时进行优化以提高字节码性能。

#5


Just having the same LOC doesn't mean building will take the same time. For example, if you add big header files like windows.h in C++, it will have to build much more for this one line.

拥有相同的LOC并不意味着建设将花费相同的时间。例如,如果在C ++中添加像windows.h这样的大头文件,则必须为这一行构建更多内容。

#6


Wow, there has got to be something else going on in that CMAKE file that isn't happening with the java project. Are automated test cases being run? There isn't anything fundamental about Java that would make it compile orders of magnitude (or any) faster than C++ code.

哇,在CMAKE文件中还有其他东西要发生在java项目中。是否运行自动化测试用例? Java没有任何基础可以使它比C ++代码更快地编译数量级(或任何数量级)。

#1


You might find this question helpful. The accepted answer doesn't emphasize a comparison to java, but you might be able to infer quite a bit about what C++ is doing that takes so long.

您可能会发现这个问题很有用。接受的答案并没有强调与java的比较,但你可能能够推断出C ++正在做什么需要这么长时间。

#2


I have to suspect that the absence of kilolines of header files is a lot to do with it.

我不得不怀疑头文件的缺少与它有很大关系。

#3


Templates are especially slow to compile.

模板编译速度特别慢。

#4


Different Optimization Strategies

不同的优化策略

Java code is typically not optimized as much as C/C++ code at compile time. This means that Java byte code is "less optimized" than "similar" native code emitted by C/C++ compilers. The JVM's Just In Time (JIT) compiler does optimizations at runtime to increase byte code performance.

在编译时,Java代码通常不像C / C ++代码那样优化。这意味着Java字节代码比C / C ++编译器发出的“类似”本机代码“更少优化”。 JVM的Just In Time(JIT)编译器在运行时进行优化以提高字节码性能。

#5


Just having the same LOC doesn't mean building will take the same time. For example, if you add big header files like windows.h in C++, it will have to build much more for this one line.

拥有相同的LOC并不意味着建设将花费相同的时间。例如,如果在C ++中添加像windows.h这样的大头文件,则必须为这一行构建更多内容。

#6


Wow, there has got to be something else going on in that CMAKE file that isn't happening with the java project. Are automated test cases being run? There isn't anything fundamental about Java that would make it compile orders of magnitude (or any) faster than C++ code.

哇,在CMAKE文件中还有其他东西要发生在java项目中。是否运行自动化测试用例? Java没有任何基础可以使它比C ++代码更快地编译数量级(或任何数量级)。