5 ms·
C++ still produces the fastest and most memory efficient programs.
by gcp 9y ago
C++ still produces the fastest and most memory efficient programs.
- rb808 9y ago> C++ still produces the fastest and most memory efficient programs. Which is the #1 requirement for a bunch of applications. I can feel I want to go back...
- nocman 9y agoFastest compared to what? Everything? That is definitely not true. If you were referring to Java/dotnet/python, well yeah. (I'm honestly curious to know what you meant).
- corysama 9y agoDefinitely not formally, pedantically true. But, we aren't defending a mathematical thesis here. We're having a casual discussion. Still... let's see: Given a generic workload with equal effort put into optimizations... Should you expect C++ to be faster? Compared to PHP, Python, Ruby, C#, Java, JavaScript: true with some pedantic exceptions. Compared to Haskell, oCaml: Usually true, unless facing both well-suited and well-tuned code. Compared to small volumes of carefully crafted and profiled Fortran, C or Assembly: usually not true. Compared to CUDA: Not true for applications well suited to GPUs. Still true for situations that map poorly to GPUs. Except CUDA is almost entirely C++! Recent CUDA compilers on recent GPUs handle C++ code directly very well. Nearly everything but exceptions and thread local storage is supported.
- nocman 9y agoMy point was that the statement "C++ still produces the fastest and most memory efficient programs." is basically meaningless without any context. There are a fair number of situations where other languages can beat C++ in either or both of those metrics. "C++ can produce very fast and memory efficient programs." would have been fine -- or some variant that compared it to specific languages, such as you do above. I don't think it's being pedantic at all to ask what the OP meant. It was a vague statement that (depending on what they meant) is either true or false.
- corysama 9y agoThen you have a much higher bar for pedantry than I do. I get annoyed when someone makes a brief, general statement and gets called out for not carefully softening it to near pointlessness. In general conversation, I'd prefer it if people assumed most statements were generalizations that are statistically significant and not proof assertions that are either True or False. Otherwise, discussion becomes extremely watered down with every statement swamped in disclaimers, softeners, exceptions and alternatives. Err... I meant "most statements except in specific situations where you are..." :P
- nocman 9y agoI get where you are coming from, and I also think there is a line where it seems you can't say anything without having to qualify it so much that it becomes annoying. It was not clear to me whether gcp's statement was supposed to be limited to a comparison between C++ and Java/dotnet/python (and I addressed that in the post that you responded to). I felt it was worth the qualification for the sake of discussion, and I still don't think it was being pedantic to ask (especially since I addressed the possibility of it being the above comparison). I wasn't just nitpicking for the sake of nitpicking. And my question was a far cry from asking him to "defend a mathematical thesis", IMHO.
- gcp 9y agoGiven an experienced programmer in all those languages that OP mentioned, I would expect the C++ version to perform faster. I didn't put much qualification because I don't think it needed it. Remember that the original question was: ...moved to Java/dotnet/python platforms...Is there a reason to use C++ any more?
- nocman 9y ago"remember that the original question was: ...moved to Java/dotnet/python platforms...Is there a reason to use C++ any more?" ^ Yeah, and I specifically addressed that possibility in my original response to you. I was just trying to clarify whether you were referring to that comparison, or a comparison of C++ vs all other languages. It was not clear to me which you meant. Perhaps it was just the way I read it at the time.
- swift 9y agoAn even better question is "faster by what metric?". Once it has been running for a while and the JIT has done its work, it can definitely happen that a Java program will outperform an equivalent C++ program because of the JIT's improved knowledge of the whole program and the dynamic execution environment. C++ can gain much of the same benefit with LTO and PGO, but it's definitely not trivial (particularly PGO) and there's not really a slam dunk win for C++. Now if the metric is startup time, that's a different story. (Though I believe there's been a lot of work on hybrid AOT/JIT since I left the world of managed languages, so maybe things are better now.)