3 ms·
"C++ did it right" seems a separate position from that put forward by the parent comment. I definitely think there's benefit to being able to view interface as
by dllthomas 10y ago
"C++ did it right" seems a separate position from that put forward by the parent comment.
I definitely think there's benefit to being able to view interface as separate from implementation, although that might well be better supported by tooling (editor folding, documentation generation) than manual maintenance - which you seem to be doing well.
I don't know whether there is benefit to being able to edit interface separately from implementation. Probably not much of one, but I could certainly be convinced otherwise.
- Retra 10y agoUsually if you edit the interface, you also have to edit the implementation. The only time I've ever wanted to edit an interface alone is when there wasn't any implementation written yet, which makes it a moot point anyway.
- jjnoakes 10y agoOne usually does want the reverse though, editing the implementation without touching the interface.
- dllthomas 10y agoIf you make substantive changes, for sure. It's possible that you may want to make cosmetic changes (or maybe change how you're specializing something where the implementation is more polymorphic?). Still, I certainly don't see much of an argument that being able to edit the two separately has much value. I'm just not entirely convinced of non-existence.
- flukus 10y agoTwo seconds of google found a .h file generator: http://www.radwin.org/michael/2011/05/10/stubgen/ http://www.radwin.org/michael/2011/05/10/stubgen/ . I'm sure there are others.
- berkut 10y agoWriting applications which have an API other people write plugins against is one: commercial apps ship the .h files, against which plugin-writers only have those and build plugins for the host apps. Yes you still obviously have to keep them in sync, but the point is you (as a commercial software vendor) can ship just the headers and keep the internal implementation details secret and change how things work completely. Which is useful for commercial vendors of software.
- Manishearth 10y agoThis isn't really an argument for .h files though. .h files are an extra amount of work you have to put in. In the case of plugin APIs, this is work you'd have to put in anyway (for a fraction of the .h files -- the ones which are part of the API). But that work doesn't have to be put in elsewhere. This is an argument for interface description files for plugins, but that could always have been done by a language with idl files or something. Indeed, apps in most other languages define interfaces via .h files because that's the de-facto plugin API description format, but they don't use .h files everywhere in the source. They only use them where necessary for the API.
- pjmlp 10y agoThis is a common myth about .h files versus modules. Most languages with native support for modules do have the necessary information stored in the binary file to enable this scenario. The only problem is exposing those plugins across languages, but it isn't a big problem if the OS has a rich ABI instead of a C one. For example COM on Windows, or WinRT the improved version of it.
- pcwalton 10y agoYou can do this in Rust just fine. The compiler can determine all the types and signatures from the tables stored in binary code. No separate .h file needed.