3 ms·
How much of a speedup did you get switching over to Rob Pike style includes?
by sfpotter 2y ago
How much of a speedup did you get switching over to Rob Pike style includes?
- cpeterso 2y agoI had to look this up: Rob Pike’s rule is that header files should not include other header files; they should only document which other header files they depend on so programmers can directly include those other header files in their .c files. https://bytes.com/topic/c/answers/217074-rob-pikes-simple-include-rule https://bytes.com/topic/c/answers/217074-rob-pikes-simple-in...
- fooker 2y agoThis seems like the kind of thing that a compiler should be good at instead of making the user jump through hoops.
- techbrovanguard 2y agoI'm glad Rob Pike didn't contribute to Go, that'd have been catastrophic to my productivity! Imagine having tools do work instead of users, it'd be like a world without lawyers. Anyhow, I've got to refactor my WIP code for the 10th time today since unused variables are compiler errors. Seeya!
- ErikCorry 2y agoIf the .h file is documenting which other header files it needs, what keeps that documentation up to date. This sounds like a very painful way to work, where .h files fail to compile (with very strange error messages because of the way C++ works) and then you have to hunt down the missing dependency.
- flohofwoe 2y agoIn my header libraries I have checks like this which produce a meaningful error message: #if !defined(SOKOL_GFX_INCLUDED) #error "Please include sokol_gfx.h before sokol_shape.h" #endif
- iainmerrick 2y agoWow, I hadn't heard of that one. It sounds very unpleasant. I have the exact opposite rule -- it should always be OK to include a header file on its own. As a corollary, headers must include or forward-declare everything they need.