5 ms·
> Damn, are we doing this wrong? Yes: Not isolating different modules sufficiently to allow you to avoid including most headers when compiling most modules. P
by vidarh 9y ago
> Damn, are we doing this wrong?
Yes: Not isolating different modules sufficiently to allow you to avoid including most headers when compiling most modules.
Patterns to do this in C++ has been well understood for two decades:
Strict separation of concerns coupled with facades at the boundaries that let all the implementation details of the modules remain hidden.
Yes, it has a cost: You're incurring extra call overhead across module boundaries, and lose in-lining across module boundaries, so you need to choose how you separate your code carefully. But the end-result is so much more pleasant to work with.
- oblio 9y agoWhile what you're saying might be true, I can't help but think about Pascal units and say: "It didn't have to be this hard! We solved this problem 40 years ago!"
- rcarmo 9y agoAnd then Modula-2 came along and... well, it was mostly the same. But the compactness of Pascal output left fond memories.
- vidarh 9y agoYes there are plenty of other solutions if you use other languages, but I decided to constrain myself to how you'd address it in C++
- nopakos 9y agoSorry, it's the same in Delphi (Pascal successor). The compilation time goes up exponentially as number of units goes up. Compilation of 2.000 files (750.000 lines) takes about 20 minutes.
- pjmlp 9y agoWith the caveat that one doesn't need to do "make world" every time a few files change.
- beagle3 9y agoThe heir to the Pascal/Delphi kingdom seems to be Nim[0], though it takes its syntax from Python. Compilation is impressively quick, even though it goes through C. [0] https://nim-lang.org/ https://nim-lang.org/
- girvo 9y agoWhich is a language I absolutely adore, and am building a homomorphic encryption based product leveraging Hyperledger on a rather obscure 160 hardware thread POWER8 server; it can definitely work for real production tasks today, even if some parts are rough (and hell, C++ can be rough too). Parallel compilation on this machine is stupidly quick :)
- dman 9y agoAny pointers to what power hardware you are running?
- robotresearcher 9y agoYou don't need pointers - just follow the fan noise from wherever you are.
- lucian1900 9y agoUnfortunately that's not feasible for highly performance-sensitive projects like browsers or games.
- bonzini 9y agoThe 90/10 rule still holds. Sometimes it's even more skewed.
- mpweiher 9y agoEven Knuth talked about it being a 97:3 rule[1] and according to some it's gotten more skewed since then[2] [1] http://sbel.wisc.edu/Courses/ME964/Literature/knuthProgramming1974.pdf http://sbel.wisc.edu/Courses/ME964/Literature/knuthProgrammi... [2] http://blog.cr.yp.to/20150314-optimizing.html http://blog.cr.yp.to/20150314-optimizing.html
- vidarh 9y agoIt absolutely is. If most of your time is spent on calls traversing large portions of a code-base that size, then you have a far bigger problem in that you'll be blowing your cache all the time. Fix that problem, and you're halfway there to creating better separated modules that can be encapsulated the way I described.
- geezerjay 9y ago> Unfortunately that's not feasible for highly performance-sensitive projects like browsers or games. Bullshit. Code needs to be compiled, but it isn't required to build everything from scratch whenever someone touches a source file. Additionally, not all code is located in any hot path.