On 7/30/2010 11:00 AM, Keith H Duggar wrote:
Actually, you have an incorrect/oversimplified understanding of Java
compilation dependencies.
And you have an incorrect/oversimplified understanding of C++
compilation dependencies.
The only thing that might cause a compile-time dependency is interface
change, or constant (static final primitive/String variable) value
change. You can safely modify/add methods in one Java file without
recompiling other Java files which depend on it. Removing members *may*
result in a link-time error, but also do not require rebuild. Modifying
constants may result in inconsistencies between references to that
constant until a rebuild.
That's all in theory. In practice, the build systems I've seen
(Java or C++, with one exception: Visual Age) use the file as
the lowest level of granularity. Which means that a change will
trigger a recompilation, even if the change won't change the
generated code.
The Java keyword "import" is not analogous to the #include directive. It
tells the compiler that "References to the imported class needn't be
fully qualified." For example, import java.util.List lets you refer to
"List" rather than "java.util.List" in the rest of the file. Importing
or not doesn't really affect compile time (there are a few exceptions,
but they are trivial, and unrelated to the classes imported.)
Yes, but that's not the question. Java's import is more or less
like C++'s using. And Java "implicitly" includes anything that
is needed, where as in C++, you have to explicitly include it.
But the inclusion mechanism is different---in C++, it's pure
texual inclusion, where as in Java, the included data come from
the compiled .class file. But the fact remains, if you modify a
..java file, the timestamp on the files will tell the build
system that the .class file is out of date, and it will
recompile the .java file, producing a new .class file. Which
will then trigger a recompile of all of the .java files which
use this .class file. Where as if you modify the implementation
code in a C++ source file (.cpp or .cc), the corresponding
object file will be recompiled, but the time stamp on the header
file (.hpp or .hh) will not be modified, and objects built from
sources dependent on the header will not be recompiled.
There are a lot of criticisms to be made for both solutions.
There's no reason why modifying the implementation of a member
function should trigger recompilation of all client sources (as
it does in Java), and there's no reason why correcting an error
in the Doxygen documentation should retrigger recompilation of
all client sources (as it does in both Java and C++---except, I
believe, Visual Age C++). It's also not a good thing that you
can get mixed versions of a class in a single program (most, but
not all, C++ systems; Java only detects this at runtime, because
it doesn't link until runtime, but it's much more tolerant with
regards to differences in the versions).