5 ms·
Java can actually compete with C/C++ if written in a specific, limited way. Some high-frequency trading shops use Java, and their entire business is speed.
by bidirectional 5y ago
Java can actually compete with C/C++ if written in a specific, limited way. Some high-frequency trading shops use Java, and their entire business is speed.
- pkolaczk 5y agoThe problem is, Java written in that specific limited way is way less expressive, less safe and less productive than modern C++, not even mentioning Rust.
- pjmlp 5y agoSince it fails to achieve 70% of the memory corruption issues that modern C++ is capable of, definitely less safe. As much as we would like the modern C++ from books and conference talks to exist in real life, that is not how the large majority of the world actually writes C++. Heck, just check the AOSP source code to see how much modern C++ it has, from one of the companies that contributes to ISO C++. Or if that fails to impress, see how much modern C++ exists in Microsoft Github sample projects.
- pkolaczk 5y agoMemory corruption / safety issues related to memory are not only typical C problems like use after free but also type errors. Optimizing Java for performance means using only primitive types which is significantly less type-safe than C++ classes / structs.
- pjmlp 5y agoC++ isn't Coq, so don't get what type safety you are selling. Naturally it is possible to write static classes that hide the internals of a data structure, and ensure they are properly used. And if that isn't enough, Valhalla is eventually here, Java 17 already includes the preview for new native memory primitives, and polyglot developers can always write a bunch of native methods, no need to throw safety and productivity away for 100% of the code.
- pkolaczk 5y agoC++ is not Coq, but it is still a lot closer to Coq than C-like Java written for performance. > Naturally it is possible to write static classes that hide the internals of a data structure Which limits you to reusing a single instance which is not only very limited in what you can do with, but also inherently error-prone compared to passing structs. Valhalla does not exist yet, had been in development for a decade, and even once they release it, it won't be equivalent to C++ structs - it is by design much more limited. Finally, productivity of Java is overrated, I've been writing in many languages and I'm not more productive in Java than in C++. Productivity is mostly a trait of a developer and libraries, not a language.
- pjmlp 5y agoNo it doesn't limit it, because that single instance class can also do JNI and manual memory management without exposing it on the public interface. I know C++ since 1993, have delivered C++ into production at CERN and Nokia Networks, and also taught it at the university to first year students. So what do I know a bit about C++ productivity versus other languages. Now if we start talking about GPGPU programming, HPC or writing device drivers then it is another matter, there is where C++ shines and will keep doing so for the foreseeable future. CERN is definitely not going to rewrite HLT in Java, in fact for some units not even C++ was good enough, and the code is actually implemented in FPGAs.