There are lots of reasons why Java is very popular:
1. Managed memory model. No dangling pointers. No buffer overruns. Much harder to create memory leaks than in C or C++.
2. Security. You can precisely control, what code can and what can't do. Private is private, you can't e.g. set a private property of an object, if you don't have rights to.
3. Huge standard library. Lots of third-party libraries.
4. Well standardized and portable, no problems with non-standard compilers.
5. High performance, great support for multicore.
6. Simple language, much fewer caveats and sharp-edges than in C++.
7. Awesome tooling.
8. Compile times orders of magnitude faster than for C++.
9. If you can't do something with Java, you can still call native code from your program.
10. Can be used to create mobile-apps and web-apps, while with C++, although possible, it is not that easy.
There are limitations to this however. One of the biggest and a major reason why people don't use Java is that Java does not provide access to the memory or the chipset. There's a whole layer that you as the programmer do not have access. And this irritates people! |
Not true. I can call to OS from Java anytime I wish. I can even call malloc, wrap it into direct ByteBuffer and use it directly from Java code, without a single line of C. We use it all the time in Apache Cassandra - therefore lots of data is kept off-heap. And as far as I know, although it is pure Java, considering performance and scalability, it beats all the other big data NoSQL database engines, including those written in C++, e.g. MongoDB.
after that I started to accept Java as a language built to support specific design patterns whereas C++ is very general.
|
In reality it is just the other way round. People use C++ only for very specific reasons now: legacy systems, low latency systems with low memory (low latency with enough memory is not a problem for Java, though), AAA 3D games, sometimes some scientific HPC stuff, some desktop apps (but this era is over, too; e.g. Firefox frontend is already using lots of JS). For all the rest, there are better, more general purpose languages and Java is one of them. For 99% cases you don't need to fit in 10MB RAM, nor have <10 ms guaranteed latency.