Originally posted by mirv
View Post
Announcement
Collapse
No announcement yet.
GCC Moves Forward With Conversion To C++
Collapse
X
-
Originally posted by curaga View PostYou've not compiled both C and C++ lately, have you?
(sorry, couldn't resist that one)
Seriously though, got anything to back up that statement, or do you believe it just because? If it's just because, you should probably go reading through the idea a bit more.
Comment
-
Originally posted by curaga View PostYou've not compiled both C and C++ lately, have you?
1. Compiling the exact same code for takes longer if you are compiling for C++.
2. One or more of the specific changes they plan to make will result in a 20x slowdown in the build
If it is 1, please explain why. If 2, please tell us which of those changes will have the effect and why. Otherwise I am curious how you justify this position. Just saying "C code compiles faster than C++ code" doesn't really mean much if you are comparing different code.
Comment
-
-
Originally posted by mirv View Postyou haven't made statements that make sense lately, have you?
(sorry, couldn't resist that one)
Seriously though, got anything to back up that statement, or do you believe it just because? If it's just because, you should probably go reading through the idea a bit more.
time gcc -o hello hello.c
56ms
time g++ -o hello hello.c
76ms
Comment
-
Originally posted by TheBlackCat View PostSo as far as I can tell, you are saying one of the two things:
1. Compiling the exact same code for takes longer if you are compiling for C++.
2. One or more of the specific changes they plan to make will result in a 20x slowdown in the build
If it is 1, please explain why. If 2, please tell us which of those changes will have the effect and why. Otherwise I am curious how you justify this position. Just saying "C code compiles faster than C++ code" doesn't really mean much if you are comparing different code.
20x is simply a ballpark figure. But it's a fact that C++ is slow to compile, especially if templates are involved, as mentioned by RealNC.
Comment
-
Originally posted by curaga View PostIt's common knowledge. Even compiling plain C with g++ is slower than with gcc, by 35% here (n=6, hello world). If you actually use any C++ features, the gap grows.
time gcc -o hello hello.c
56ms
time g++ -o hello hello.c
76ms
Now if you want to talk about how it's easier to abuse C++, which results in increased compile time, that's entirely different. Let's look at the flip side too: for comparable structures, if not using STL, then something else has to be written, which may be written poorly. Actually, you could theoretically save compile time in some areas due to OOP principles (who knows? that's why gcc-in-c++ is being looked at). You could also make it worse - none of which is a reflection on the language, but rather on the how it's being used.
Now let's also look at C++ vs C in terms of pure semantics which must be observed...in which case, sure, C++ has a bit more in the lexical analysis which must be handled (for example), but such overhead is going to be nowhere near what you're claiming - it's mostly likely going to be completely unnoticed.
Comment
-
Originally posted by mirv View PostWhich is like using glxgears for opengl benchmarking.
Code:./configure CC="g++" CFLAGS="-fpermissive -Wno-write-strings" CXXFLAGS="-fpermissive -Wno-write-strings" --without-cxx-binding make -j4 # to warm disk caches make clean time make -j1 real 0m47.392s user 0m41.033s sys 0m4.815s
Code:make distclean ./configure CFLAGS="-Wno-write-strings" CXXFLAGS="-fpermissive -Wno-write-strings" --without-cxx-binding make -j4 # to warm disk caches make clean time make -j1 real 0m42.323s user 0m36.326s sys 0m4.294s
Comment
-
Originally posted by curaga View PostIt's common knowledge. Even compiling plain C with g++ is slower than with gcc, by 35% here (n=6, hello world). If you actually use any C++ features, the gap grows.
time gcc -o hello hello.c
56ms
time g++ -o hello hello.c
76ms
Comment
Comment