3 ms·
You missed my point entirely, I think. Yes, if you want to write a loop doing a single type of processing, numerical or string, you can typically write better
by pnako 6y ago
You missed my point entirely, I think.
Yes, if you want to write a loop doing a single type of processing, numerical or string, you can typically write better code in C++, or a shader language.
Most business applications don't follow that pattern at all. It's a mix of many types of operations. Look at the Techempower benchmarks, for example; the Java frameworks tend to do better than the C++ ones, at least when it comes to throughput (C++ is more competitive when it comes to latency).
I believe it's due to the HotSpot compiler doing aggressive, profile-guided optimization (you can do AOT profile-guided optimization but few people actually do it; in Java you get that automatically) as well as the garbage collector. Memory allocation is a fast as incrementing a pointer. Whereas C++ will tend to do way more housekeeping; in Java that housekeeping is amortized when you call the GC. That hurts latency but helps throughput.
- kllrnohj 6y agoIf your workload is heavy memory allocation churn then yes Java will absolutely be a better fit, or really any language with a good GC. But that's not "string & numerical" processing. As for Techempower the top framework by a landslide is in Rust, not Java. That's a matter of if the framework is optimized to win at Techempower or not, wasn't that the lesson actix taught everyone?