4 ms·
Stroustrup as always fails to recognize the vast surface area of C++ features, foot cannons, and the heavy weight of C compatibility around C++ neck. C++ barel
by Scubabear68 3y ago
Stroustrup as always fails to recognize the vast surface area of C++ features, foot cannons, and the heavy weight of C compatibility around C++ neck.
C++ barely made sense in 1995. It makes absolutely no sense today.
- jeffbee 3y agoI think the funny thing is you no longer even get peak performance from C++. In many ways Java is running rings around C++ performance. Partly, it's because you get state-of-the-art peak optimizations for free from Java, and you'll need a team of 20 full-time build engineers to get a peak C++ artifact with PGO, LTO, and post-link optimizations. Partly it's because the speed of C++ is illusory, with the superficial success coming at the start of a project, followed by years of monotonic performance degradation as the flaws in the original are iteratively discovered and remediated. We see this very clearly with gRPC, where the performance of the C++ implementation has been cut in half over the last 3 years while the Java implementation, which is faster today than ever before, is the performance champion.
- eclectic29 3y agoI acknowledge C++'s safety concerns, but no, Java is definitely NOT running rings around C++ perf. Not a single AI/ML model is implemented in Java. The core of AI/ML runs on C++ only. You may see a lot of Python, but the core engine that Python is wrapping is written in C++. Sorry to break it to you but Java cannot even come close here.
- jeffbee 3y ago"Multiply an insane amount of stuff" is not an interesting point in complexity-safety-performance space.
- miffy900 3y ago> "Multiply an insane amount of stuff" is not an interesting point in complexity-safety-performance space. So in other words, Java is bad at scaling a basic math operation like multiplication? > "In many ways Java is running rings around C++ performance" The AI-space is proof positive of that being false. C++ is kicking Java's butt, squeezing literally trillions of ops per second of performance, all of this happening before the Java runtime can even startup. The first transformer-based language model was built with PyTorth; imagine if PyTorch was a python wrapper for Java code instead of C++ code? It'd be garbage. I mean how freaking long did it take for Java to even get a basic Vector API? C++ devs have been writing SIMD optimized code for years now. And besides that, try getting a Java program to scale at tens or even hundreds or thousands of GPUs for a large language model. You'd need GPUs with literally 20-30% more RAM just to accommodate the GC.
- lostmsu 3y agoThe reason for that mostly is CUDA only supports C and C++ natively.
- eclectic29 3y agoTry writing high performance math in Java even for CPU.
- Cloudef 3y agoIm not sure which one is the more delusional, java or c++ gang. That said being familiar with google's c++ (especially protobuf) codebases, i dont doubt your claims. Lets just say theres reason people use alternative runtimes like nanopb.
- nightowl_games 3y ago> you'll need a team of 20 full-time build engineers to get a peak C++ artifact with PGO, LTO, and post-link optimizations. As someone working in a team of 3 with a c++ code base this statement is hilarious hyperbole.
- jeffbee 3y agoHow do you explain the almost complete absence of peak-optimized software in the real world? Percona, an entire company dedicated to supporting one stupid program, does not offer a PGO MySQL, much less a BOLTed one. "Try to enable PGO" is still an open issue for Envoy, an 8-year-old project with multiple gigantic companies contributing.
- CyberDildonics 3y agoHow do you explain the almost complete absence of How do you explain the almost complete absence of consumer software written in java where performance matters? Web browsers, databases, video codecs, high end games, all written in C++. According to you they should all be written in java for maximum performance.
- CyberDildonics 3y agofollowed by years of monotonic performance degradation as the flaws in the original are iteratively discovered and remediated. This doesn't make any sense and nothing in this comment is something an experienced optimizer would say. I'm not sure where the fantasy comes from that java is going to beat C++, but anyone experienced in optimization is going to control their memory allocations, then control data access being linear so the prefetcher works well, then control memory alignment, then worry about SIMD and multi-threading. When people talk about optimizing in java, it's usually about turning off the garbage collection, fighting with the garbage collection etc. Memory allocation is trivial in C++ because so much ends up on the stack and preallocating memory is trivial. Java optimization gets stuck on step 1, trying to control memory allocations and pointer chasing. Show me a program in java and I will show you how it can run faster in C++ (and possibly even faster in ISPC).
- Scubabear68 3y agoC++ 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.