5 ms·
I think I'm the only person who likes headers. I'm not overly concerned with compilation times and big-o notation. Computers can compile things really fast nowa
by SeoxyS 14y ago
I think I'm the only person who likes headers. I'm not overly concerned with compilation times and big-o notation. Computers can compile things really fast nowadays.
I'm more concerned with the developer usability benefits & drawbacks of the feature. As somebody who is a polyglot, but spends a large amount of time writing Objective-C, I have come to absolutely love header files.
I see header files almost as documentation. To me, a header file is a description of everything that's public about an API. My header files tend to be very well commented, and very sparse, only containing public methods and typedefs.
When the need arises to make internally-includable headers (say I'm writing a static library, and have methods that are private to the library, but public to other classes within the library), I will usually write a `MyApi+Internal.h` header for internal use, which doesn't ship with the library.
A developer should never have to dig into implementation files, or into documentation, in order to use a library. Its headers ought to be sufficient. Things like private instance variables or anything private does not belong in a header file.
FWIW, here's the public header for the library I spend most of my time working on:
https://gist.github.com/e83169d2c3984c6f077c https://gist.github.com/e83169d2c3984c6f077c
- nnethercote 14y ago> Computers can compile things really fast nowadays. Not if you're working on a large project. Firefox takes about 15 minutes to build from scratch on my fast Linux box. Getting that down by a factor of 10 or more would be fantastic.
- gilgoomesh 14y agoThe headers still exist. This proposal is not about eliminating them. All this proposal does is bundle groups of headers together and give you a simplified way of including them. If you have a look at the proposed ".map" files, the headers are still fully enumerated. I assume the IDE/debugger will still be able to find definitions in the original header files via the .map files.
- tikhonj 14y agoIt sounds like you'd really like OCaml's module interface files (.mli). Or, more generally, all of OCaml's module system. It's very well designed and definitely worth checking out.
- anextio 14y ago> Computers can compile things really fast nowadays. Tell that to my fecking codebase.
- pjmlp 14y ago> Computers can compile things really fast nowadays. You are free to take care of our > 1 hour compile time build.
- masklinn 14y ago> Computers can compile things really fast nowadays. Compiling Qt or LLVM from source will quickly put a rest to these unwarranted assertions.
- tsahyt 14y agoNo, you're not alone. I view headers as a wonderful way of documentation as well. Usually I've got a header file open on the left side of the screen while working on the implementation on the right side. It's extremely convient to work this way. I'm aware of the performance issues headers create at compile time but I still like them quite a lot. On the other hand I haven't really been too fond of any module system I've seen so far. Maybe I'm just extremely old fashioned.
- jandrese 14y agoMost of the time header compilation time isn't a big deal to me either, but then I started working on a project that uses Boost extensively and noticed that even small files were taking several seconds to compile because the headers were so enormous.