←back to thread

196 points svlasov | 2 comments | | HN request time: 0.63s | source
Show context
Dwedit ◴[] No.40851285[source]
Compile time or runtime? Compile time reflection would be completely painless and bloat-free.
replies(3): >>40851300 #>>40851330 #>>40851736 #
thechao ◴[] No.40851736[source]
Having implemented reflection in languages like C(++), before, it is most certainly not bloat-free. There are sorts of 'obvious' things programmers do (like enum-reflection) that end up injecting strings all over the place. The overhead is (worst case) proportional to the source-code size, in those cases. In other cases, you end up with bloat proportional to heavily-utilized template libraries. However, unless the reflection system is very clever, i.e., exposes enough information to the linker to strip duplicate-ish symbols, you end up with a bunch of reflection copies.
replies(2): >>40852644 #>>40852761 #
zarzavat ◴[] No.40852761[source]
I always thought it’s good practice in C/C++ to have only one translation unit in release builds e.g. SQLite amalgamations, instead of relying on LTO. It also speeds up compilation because it isn’t recompiling the same header files over and over again.
replies(2): >>40853586 #>>40854808 #
kccqzy ◴[] No.40853586[source]
It's a cute idea but just not scalable. It doesn't speed up compilation because separate translation units can be compiled independently and cached.
replies(2): >>40855459 #>>40855583 #
1. account42 ◴[] No.40855583[source]
It does significantly speed up clean builds in many cases, to the point that those clean builds can even be faster than many "incremental" builds in some cases.
replies(1): >>40859824 #
2. kccqzy ◴[] No.40859824[source]
I do not know of any compiler that can compile different parts of a translation unit in parallel. But plenty of systems (including the venerable `make -j`) can compile separate translation units in parallel because they are independent.