The premise of the question is not entirely correct.Companies use C++ in equal proportions, it depends very much on the use case.
There are a handful of things that speak for Java:
- Java is the standard for web applications.
By that I mean servlets. There is a certain degree of standardization such as WS-RS, JAX-RS. You can build something like Restful Web Services with all sorts of languages and frameworks, but only for Java there are proper standards for this.
Java Crasht (almost never) to desktop. The resource consumption is capped upwards by heap (even if this has since softened) and can therefore be calculated. A Java application is therefore less likely to paralyze the whole system with a memory leak (yes, yes… exceptions). The error-handling mechanisms – even if very annoying for developers – are very robust and work well. Problems can be traced exactly and do not have to be searched for eternities.
Hardly any other programming language (!= environment) allows such debugging and profiling as Java.It is comparatively easy to debug and profile code, even in very complex applications. Even if the latter only goes reasonably well with third party tools like Performance and Memory Java Profiler.
Many things (such as queues) offer native thread safe implementations.Many other languages still don’t do it right (e.g. Python) or can quickly backfire (C++).
Many constructs are pushed by language and tooling (e.g. Eclipse). Man really has to make an effort to make some false type casts in Java, to create memory leaks or similar.
Java is not faster than C++, but very close to it. The small loss makes up for the runtime and languages with comfort and portability.
It is important to understand that for larger companies, the “coolness” of a language is less important than the operational operation of projects.Languages such as Python cannot reach Java in points of power and performance. Others are less sophisticated in tooling or have more cumbersome build processes.
The only language that is similarly strong remains C++.With its much smaller footprint, slightly better performance, and non-existent bootstrapping time (the JVM takes time when it starts), C++ is the better choice for many use cases. Pretty much all small devices are programmed in C and C++.With the IOT hype, this will only become more.