"Programming in C++ is premature optimization"
does everyone do some people say this?
|show 9 more comments|
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.
People often say this (somewhat tongue-in-cheek, in my experience) as a dig against C++ as a choice of language. People typically choose C++ because it is, in most cases, faster than an alternative like Python or Java. However, most of the time, the additional speed gained is not really needed. When a person says "Programming in C++ is premature optimization" they are saying that you could have programmed your application in some other language, been done much faster, then if you needed to make some part of your code really fast, you could simply code that part in C++ and call that routine from the other language.
Because they don't know how to program in C++.
Generally speaking, such people simply don't understand how to program safely (and quickly) in C++ and suggest that doing so takes up an inordinate amount of time or somesuch rubbish. If it really was significantly slower, then people would only do it to make their programs run faster, as C++ is easily the fastest mainstream language. That would make it an optimization- "I'd rather program in C#, but I have to use C++ because it's faster.", and usually premature because most optimizations are.
However, this is usually ignorant. C++ hasn't been a hassle to program in since
Edit: Sorry, I wasn't sufficiently clear. I forget when speaking to non-C++'ers how little they generally know about the language, as I usually just stick in the C++ channel on SO. First,
Now, I'll be the first to admit that I'm not on the cutting edge of languages like Python, Java, or C#. But as far as I know, Java and C# have nothing as strong as templates. Java's generics are hardly good for anything, and C#'s aren't that much better. For example, I use an expression template to automatically generate a finite state machine. I've never seen anything like that. If I was coding in Java, I'd have to code it manually.
|show 16 more comments|
Well, that's because programming in C++ does not magically give you any performance boost over, for example, Java. You need to do it very well, and doing that in C++ is definitely not an easy task. Also time consuming and programmer's time is not cheap...
|show 7 more comments|
I haven't used C++ in a long time (and never templates), so this is from memory based on other questions on Programmers.SE and on StackOverflow:
Templates are handled at compile time, and C++ allows you do do some crazy tricks with complicated ones.
Because they're handled at compile time instead of runtime, all that execution is "optimized" away, leading to compiled code that could in some cases be faster than C, because the optimizations done are complicated and hard to to by hand.
And it's "premature" optimization because this is done before any testing for speed ;)
If anyone with experience wants to add/fix what I remember, please do. Don't just downvote.