Does speed vary for different compiled languages? (e.g. Java vs C ++)

I just love to program, but I was wondering if you write two identical programs in two different compiled languages ​​(for example, java and C ++) and run them after they are compiled, is the execution time different or is it just the compilation time that is different?

+4
source share
2 answers

The thumb rule is interpreted (compiled on the fly) slower than precompiled, compiled to a virtual machine, like Java, slower than architecture dependent, and the procedure is faster than OO and assembler faster than procedural (but you don’t wear it I want to use this if you are not programming something like a PIC microcontroller for an industrial application, or you are not like Neo and Jedi programming)

In any case, each language has some advantages and disadvantages, as well as good optimization (identifying bottlenecks and increasing productivity at these specific points) can make your program faster than any other careless implementation, no matter what language ...

+6
source

Java code is slower than C ++. As with any research, the numbers can vary greatly. Usually you see 20% slower than C / C ++, as most in favor of Java. Wikipedia compares them in more detail.

Other sources say it uses 50% more memory .

In short: Java is slower than C, C ++, and other languages ​​that compile into machine code (compared to Java bytecode ).

+1
source

Source: https://habr.com/ru/post/1385702/


All Articles