3 ms·
> How can _any_ language compile a unit passing a struct Foo on the stack without knowing the size of Foo (and thus having to read, say, foo.h)? by having a ru
by ddlsmurf 6y ago
> How can _any_ language compile a unit passing a struct Foo on the stack without knowing the size of Foo (and thus having to read, say, foo.h)?
by having a runtime that has higher level instructions like "change that field" moved the onus of knowing where the field is onto the runtime. Another answer is that it's the difference between needing to parse text everytime and having some binary intermediary description (which both delphi and c# have, compare .obj to .dcu and an assembly). This means there is less work to do when a dependency changes in incremental compilation.
- Galanwe 6y ago> Another answer is that it's the difference between needing to parse text everytime and having some binary intermediary description This is an implementation detail to me. Most C++ compilers _do_ compile headers if you tell them to. > by having a runtime that has higher level instructions like "change that field" moved the onus of knowing where the field is onto the runtime Alright but that's not the same language anymore. With such a runtime you don't compile natively anymore, you compile for a VM that will dynamically allocate stack space and translate adresses.
- TazeTSchnitzel 6y ago> This is an implementation detail to me. Most C++ compilers _do_ compile headers if you tell them to. C and C++ compilers will pre-compile one header if you ask nicely, the first one you include. Compiling multiple independent headers is very hard, though. C and C++'s header time complexity hell is not an “implementation detail”, every compiler has to suffer with it. The C preprocessor is a fundamental design problem.
- Galanwe 6y ago> C and C++ compilers will pre-compile one header if you ask nicely, the first one you include. Compiling multiple independent headers is very hard, though. Are you sure this is the case? my interpretation of clang's documentation does not confirm this. From what I understand, the at the very least headers are pre-parsed to an AST. At best, they are fully precompiled. I don't see mentions of restrictions on the number or nesting of headers. > The C preprocessor is a fundamental design problem. Come on, this is a huge overstatement. While I can agree that a textual replacement based preprocessor is not the sexiest of things, it does have the advantage of being pretty much limitless, simple to grasp, and implement.
- hawski 6y ago> The use case for precompiled headers is relatively simple: when there is a common set of headers that is included in nearly every source file in the project, we precompile that bundle of headers into a __single__ precompiled header (PCH file). From https://clang.llvm.org/docs/PCHInternals.html#design-philosophy https://clang.llvm.org/docs/PCHInternals.html#design-philoso... (emphasis mine)
- TazeTSchnitzel 6y ago> While I can agree that a textual replacement based preprocessor is not the sexiest of things, it does have the advantage of being pretty much limitless, simple to grasp, and implement. …and is a fundamental performance bottleneck. Why is it an overstatement? I agree it's simple and flexible, but compilation performance suffers regardless.