If the idea is for the compiler to read only the headers of imported
modules, then you have a C+±like mess: any generic or (unless you want to
give up on non-LTO operation) inline-worthy functions would have to be
stuck in the header, and you have constant tension between dumping stuff in
there to take advantage of these things and leaving it in the source file
to keep things prettier (and increase compilation speed, but no reason to
think /that/ would be recreated).
Meanwhile, it’s not actually necessary to do this to get incremental
compilation. On the contrary, a superior method to C’s is to have the
compiler manage it and maintain dependencies at a finer grain than
per-file: thus only one function in a large source file may need to be
recompiled; (critically) modifications in a file containing API or
structure definitions need only force recompilation of code that relies on
the particular items changed, unlike the situation with C++ where touching
some common header often means recompiling the entire project; and
modifications to generic functions need not cause recompilation of
dependencies unless they were actually inlined into them (since this won’t
happen at -O0, this is a nice benefit when prioritizing compilation speed
over all else). Oh, and since this is basically equivalent to LTO, you get
better inlining (i.e. across source files) without needing to redo codegen
from scratch every time, like normal LTO.
If you do this, use of header files would have negligible benefit to
compilation speed. Rust does not currently have anything of the sort, but
I heard someone was going to work on incremental compilation, which I hope
is something along the lines of the above…
If header files are to be consumed chiefly by humans, as documentation
and/or to more clearly visualize what API is being exposed, that does not
apply. However, I’m not sure how much advantage they have over
Javadoc/librustdoc-like generated documentation. (I can definitely get
behind keeping it in the editor rather than needing to use a slow web
browser. But this doesn’t need to be part of the language.)