Quote from dholliday:
Intel and AMD (and others) want software to run as fast as possible on their chips so they have labs where they test different languages. They work to make sure their chips support what is needed for various languages to run fast and also suggest improvements to the language compilers. Now hypothetically, say you knew someone at one of these labs, and asked them which was faster; Java or C++. Well, yes it does depend. But the answer (hypothetically of course) will be Java (and I assume C#). In fact Java has been faster than C++ for several years. Yes Java is slower to start up (the JVM has to start). Yes Java will take up more memory and run slower at first but ultimately, Java is faster. Memory allocation and destruction is an order of magnitude faster. The JIT (just in time compiler) optimizes the code as the program is running (hence running slower at start up), optimizing the code to run as fast as possible on the particular chip (they are different). Now even if this was not true, there is a fundamental reason why C++ will never be as fast a Java again⦠pointers. I use to love pointers, but a C++ compiler can NOT KNOW what a pointer points to. The Java JIT knows what everything is so it can do optimizations that a C++ compiler canât. As a simple example if the program multiplies an array of numbers by another array of numbers, and does this often. The Java JIT, knowing what the type of the numbers are and that that they are used over and over again can store them in a register as needed, the C++ compiler canât, it canât guarantee that the numbers are floats or ints, or a string for that matter.
Then there is garbage collection. There are now garbage collectors that run in their own thread and on their core if you have a multi-core machine.
Java is now used very heavily on Wall Street.