Why is Java Slower than C++ Programs



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.
Updated on: 2020-06-13T14:02:33+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements