What C++ Doesn’t Know in Java


The features below are left out in Java either because of security reasons or because of their uselessness.


Java shuffled off the pointers which C++ is notorious for, due to the danger accompanying it. It’s not easy to master the pointers, and allowing Java to access memory directly would expose it to security problems. As a trade-off, Java objects are passed head-on as arguments, and Java arrays demand indices to get manipulated.

Header Files

Java doesn’t use header files for two reasons: 1) it is not possible to use a library that declares a method without using it, 2) it is more difficult to program using files that are out of synchronization with the implementation (this point is still unclear to me, probably, due to my lack of experience with header files). Trade-off: not using header files = not using the advantages of header files (especially in prototyping and documentation).

Multiple Inheritance

Again, security. Multiple inheritances can get really messy and is one of the main causes of C++ bugs. Instead, Java uses interfaces, which are easier to master. The most problematic aspect of interfaces is that you have to code every method in them.

In addition to the three features above, Java also left out #define, typedef, and structs, I suspect, because of their “usefulness degree”.

In addition, below are some features of Java which C++ doesn’t have.

Java introduced Garbage Collector into its implementation (due to the lack of pointers), and made the use of exceptions easier than in C++. Because of the String class, strings are not treated as the array of characters anymore, which eases the functionality. The super operator helps us to find the class in Java that our current class extends (super-class). C++ modifiers are extended to improve security (e.g. abstract, synchronized, native, final). Another operator, instanceof is very useful while defining the type of an object, whereas helper programs (javadoc and javap) contribute to documentation.

For more details, refer to the book Java Programming Language Handbook by Anthony Potts & David Friedel.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ismayil Shahaliyev

Ismayil Shahaliyev


International Chess Master | MS in CS & Data Analytics (ADA & GW Universities). See the full list of my articles at: http://www.shahaliyev.net/writings.html