3 ms·
C++ does indeed give you this level of control. Most C++ code I have seen does not even approach this level of care and customization. When we are talking abo
by Scubabear68 3y ago
C++ does indeed give you this level of control.
Most C++ code I have seen does not even approach this level of care and customization.
When we are talking about speed, most people mean basic out-of-the-box speed of the code without heroic efforts. C++ and Java are a wash at this point performance wise. Most analytics code I have seen on Wall Street was either Java or C++, with the choice driven by what the quants wanted in their resume, not performance.
- jeffbee 3y agoEven the heroes eventually capitulate to complexity in C++, compromising performance. It is virtually impossible to write a realistically complex zero-copy RPC server in C++ because the lifetime issues are too daunting. You don't get it "for free" in Java but because the language and the JVM have formalized the lifetime problem you can write a zero-copy RPC service very, very cheaply. Even Go can beat C++ in this use case, for the same reasons. All the other stuff in this thread amounts to toy problems, from a software engineering complexity standpoint. Yes, you can write a fairly good CFD kernel in C, C++, or fortran. There are no lifetime or boundary issues in these use cases. The safety of the language in such cases is of no interest.
- CyberDildonics 3y agoEven the heroes eventually capitulate to complexity in C++, compromising performance. It is usually dead simple. Reserve memory in a vector, put data in, loop through it linearly. Modern C++ is very simple most of the time. Where are you getting this idea? It is virtually impossible to write a realistically complex zero-copy RPC server in C++ because the lifetime issues are too daunting. This is not only untrue, it doesn't even make sense. What is it that you think can be done in java and what are these lifetime issues you think are in the way? You didn't give any actual technical examples, so feel free to show something real and back up this claim. Even Go can beat C++ in this use case, for the same reasons Prove it, let's see where these ideas are coming from, because I don't think they are coming from experience with C++. The safety of the language in such cases is of no interest. This is also overblown in modern C++. It is easy to boil things down to value semantics and let simple lifetimes manage resources with scope. When it isn't something you can do with scope and you have to manage resources yourself, the language won't help you anyway since you are writing it yourself.
- jeffbee 3y ago> Reserve memory in a vector, put data in You've already proven that you don't know what I am talking about and now you are doubling down. There is no way to put data into a std::vector without copying it. Vector can't adopt memory that already exists. So your plan doesn't suit the use case I am discussing: zero-copy RPC servers.
- CyberDildonics 3y agoFocus up, these are two different things. You said complexity, I said looping through a vector. You said "zero-copy RPC servers" (for some reason) but never gave any evidence of what you are saying or explained it technically in any way. I'll ask again, show me what is being done in java that can't be done in C++. Show me technically, prove what you are saying. I know how these conversations usually go. It's mostly the other person trying anything they can to not give evidence of what they're saying.
- CyberDildonics 3y agoMost C++ code I have seen does not even approach this level of care and customization. True, but all of this isn't neccesary to be faster than java. When we are talking about speed, most people mean basic out-of-the-box speed of the code without heroic efforts. Fair enough in general. All it takes in C++ is allocating memory out of hot loops and looping through memory linearly. This basically eliminates memory allocation as a bottleneck and pointer chasing as a bottleneck. These two things alone can make a program 100x faster or more. In C++ makes this is often the simplest possible way to do something, although unfortunately that doesn't mean programs are always done like this.