Why is Java slower than C++ programs?

Java Programming Java8Object Oriented ProgrammingJava Technologies

Modern Java is quite fast and is comparable to C++ code base but it still takes lot of memory. Slowness of Java programs is primarily because of bad programming practices. But following areas are where Java can be improved.

  • Java libraries are written keeping readability and correctness in mind, not performance.
  • Slow String based operations as Strings are UTF-16 encoded objects and are immutable. So more String are used, more memory is required.
  • Boundary checks on arrays also make its operations bit slow.
  • I/O Stream operations are slow considering synchronization checks on each access.
  • Lacking low level functionality like C also attributes to slowness in some cases.
  • Most of the servers are tied to older version of Java causing the slowness.
raja
Published on 19-Jan-2018 13:28:29
Advertisements