3 ms·
[note: I use both C and C++ heavily, and I think you are interpreting Bjarne wrong here] the use of which will in turn increase compilation times sure, but th
by stinos 13y ago
[note: I use both C and C++ heavily, and I think you are interpreting Bjarne wrong here]
the use of which will in turn increase compilation times
sure, but that does not makes anything he says about it less true. You could even argue it has nothing to do with the discuession at all.
I cannot see how you would implement strlen or malloc in C++ more efficiently than C
He says "C is not more efficient" which means "C++ is as effecient, or more efficient". Which in turns means you are right, and he does not imply you are not (that's the "as efficient" part). Yeeha, you're both right, no need to start a war.
Stroustroup would suggest library then to be wrapped to make it behave according to C++ style
I'd rather think he'd suggest the library should have been written in C++ in the first place. Which is definitely shorter and better by his metrics.
The most convincing is maintainability
which again comes down to the "as efficient" part then.
- eliasmacpherson 13y agoCode that takes longer to compile is not better, more efficient, more maintainable. A C++ compiler will take longer than a C compiler to produce the same code from some C source code, providing it will compile, because they are not an exact match. I could argue about compilation times until I am very blue in the face, but I'll leave it at that and I won't do it here. I am saying that I think that it will take more C++ than C to write malloc or strlen, because of casting to void, so I am saying he's wrong. I could be mistaken however. I think a wrapper is less of stretch, to suggest that a library be rewritten in C++ as a defence of the simplicity of C++ would suggest a very large amount of cognitive dissonance.
- CJefferson 13y ago"A C++ compiler will take longer than a C compiler to produce the same code from some C source code" While this is technically true, I have in the past measured this, and the difference on my code when optimising was < 5%, so I think nothing to worry about.
- eliasmacpherson 13y agoBasically if you had to get a distro out the door, and 100 days to do it, given your example, if the code was written in C with a C compiler, you'd be done 5% quicker. It's not the sort of thing you can measure once and just forget about. Then of course by moving to a C++ compiler, the temptation is to use features that take forever to compile!
- eliasmacpherson 13y agoThis isn't really relevant to your point or to the discussion, but this is not the first time I've heard of these kinds of improvements in compile time: http://tech.slashdot.org/comments.pl?sid=4410261&cid=45332543 http://tech.slashdot.org/comments.pl?sid=4410261&cid=4533254... Obviously, what's being compiled is not exactly equivalent but the time difference is startling.