They're also bad as an overview. They may have been good in the 1980s, but nowadays a proper documentation generator gives you better formatting, search features, and cross-references. Inline documentation is particularly obnoxious in header files: I like seeing function-level documentation alongside interface and implementation, but if I put the documentation in both the .cpp and the .h file it's duplicated in two places and easily gets out of date.
I have the feeling that the difference matters to almost nobody and should be avoidable by the few people it actually affects. I had more issues with colliding include guards than I had with symlinks and I still end up replacing CLASSNAME_H with PROJECT_CLASSNAME_H in our own headers every now and then since the autogenerated guards are too naive.
Include order is a valid complaint, the others truly are non issues.
I mean, we have other more pressing issues. Such as the fact that garbage collection is still a thing in 2018.
> ...but nowadays a proper documentation generator gives you better...
Examples of that?
> I like seeing function-level documentation alongside interface and implementation, but if I put the documentation in both the .cpp and the .h file it's duplicated in two places and easily gets out of date.
This is the only thing that I dislike about header files. And it is a constant reminder how bad IDEs are at handling this.
I hope he meant something else since he said "nowadays". Doxygen is ok if you haven't setup your build environment. But for when you actually are in the code (and somewhat familiar with it) I very much prefer just reading the header files than switching to a browser.
This happens because there is some redundancy between the header file and the source. You can often arrange your code so that there is no redundancy (or almost zero).
how so ? every IDE I've used automatically changes the header if you change the cpp and conversely
Dear lord, all those broken builds I've seen over the years would love to talk to you about that.
Why aren't Delphi, Oberon, and Modula-3 immensely better? Each file is an independent module except the one with main. Then the compiler quickly figures out in one pass what all the function signatures are. The minor drawback with this is that the one-pass method requires you to pay attention to declaration order, though a two-pass method renders that approach irrelevant. The IDE has all the symbolic goodness you need, and no goddamn header files. Also it's still easier than dealing with managing the dependency graph yourself as is necessary with C file include order.
I say this as a guy who enjoys C and has done way more work in C than Delphi, but give credit where it's due.
Headers (or at least 'separate specification of API') are/is great, and I miss it dearly in other languages.
Already in Turbo Pascal for MS-DOS there was a TPU dump tool, which would generate a "header file" from a TP module.
"Uses BGI;" and I'm done :)
Thankfully there is Bitsavers.
"Circular Unit References" chapter on the Turbo Pascal 5.0 programmer's user guide.
https://archive.org/details/bitsavers_borlandturVersion5.0Us...
But they don't.
Also, a header file will hopefully be logically structured by a human. Something generated by the IDE will not.
You could even make them part of the build, if you want a continuous up to date version.
That makes a huge difference.
Modula-2 does it better. Each module split in two files - definition and implementation. Unlike C++ header files, def files are compiled rather that inlined, so they don't have a potential to produce different result for each source file that references them. The result is 100% reliable dependency graph across all source files, no need for a makefile, and blazingly fast compilation (each def file is only parsed and compiled once).
[1] https://discuss.ocaml.org/t/what-is-the-reason-of-separation...
But still, no IDE or tool I've seen does this better. A header file gives you a very nice overview, and it really isn't any hassle to speak of to keep them up to date.
It takes getting used to (as with everything when starting out with a new language), but before you know it you might even start to miss them in other languages.