views:

266

answers:

6

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

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.

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

+4  A: 

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

chaos
And preprocessor in general.
luiscubal
precompiled headers helps here, right?
dfa
@dfa: Yup, bunches.
chaos
+4  A: 

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.

Greg Mattes
A: 

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.

AgileJon
Compilation no, but sometimes it's the linking that takes hours.
Matt Kane
You sir, are wrong.
Malfist
Pwned! Serves me right for taking an uneducated guess
AgileJon
+2  A: 

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.

schnaader
+4  A: 

Templates are especially slow to compile.

Martin Cote
+3  A: 

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.

David Berger
The link points to very well thought out answer. thanks!
Jon