Question:
If Java is limited, why do programmers use then? Why not switch over to C++?
Raghavendran
2017-03-18 08:43:48 UTC
If Java is limited, why do programmers use then? Why not switch over to C++?
Ten answers:
Robert J
2017-03-18 09:31:35 UTC
"Horses for courses" - it depends what that particular programmers targets are and what type of software for what operating system and environment (business, web, gaming etc) they are working on.



For eg. business programs like some form of accounts, MRP or contact management system (or anything else with user interaction a screen at a time), Java is perfect - it needs writing once then can run on any system with java support.

An application like that does not need low-level hardware support and is not updating the screen at a high rate, so portability and crashproofing are more important that raw speed.





For real-time, speed critical software like games, industrial PLCs or operating systems - C / C++ is far better. A program needs compiling differently for each different type of system it will run on, but will run at the best possible speed on each.



For a web server back end with database facilities, PHP [as part of a LAMP stack] is likely to be the best choice.



For some types of AI development, LISP or similar.



For specialised hardware interaction with little or no user displays or input - Erlang may be a good choice.





There are hundreds of different programming languages, each with advantages and disadvantages for different types of use.



The best for you depends on what types of software you are developing and for what types of device or operating system.
aloha
2017-03-27 21:23:45 UTC
simply put; java is a beautiful language, c++ is not.

java isn't limited, you can use native libraries.
Hardeep
2017-03-22 09:49:59 UTC
asdadsad
web
2017-03-21 10:25:09 UTC
Every language has a style and paradigm.

Java does not support accessing the memory addresses. Java is kind of strictly object oriented.

But having all references that are not modifiable is good in several contexts and not so in other contexts.

It is like the famous C++ saying - you pay for what you use.
Alex
2017-03-19 21:52:59 UTC
Write once, debug everywher-- sorry, I mean run anywhere.
husoski
2017-03-18 15:48:08 UTC
What do you mean by "Java is limited"?



I have some ideas, mostly developer-oriented, that may not be what you're thinking of.



First off, Java--alone--is a far superior platform for developing applications to C++ alone. There are no standard C++ classes or libraries for developing a user interface, networking, managing a file system, security, data compression, etc. All of these exist in the Java SE platform.



C++ has limited support for object oriented programming, since polymorphism only works when objects are accessed explicitly by reference or through pointers. Java solves this by having *all* object access through references, so maybe this is a limitation of Java. But C++ "references" are tacked onto a C memory model that uses pointers and manual memory management.



Intelligently used, C++ can be used to create efficient and easily-maintained software systems, but it usually takes a lot of "plumbing" in the classes to get things right; and even then, simple coding errors can cause an indecipherable avalanche of error and warning messages.



The resulting program written in C++ isn't always faster, either. I had a private embarrassment several years ago when Ratchetr (still leading the answer-board here even though inactive for a couple of years) posted a short C# solution to a question here (sorry, can't find the link...searching old Y!A answers is nearly impossible). Something involving summarizing a dataset by building a hashed dictionary. I started to answer that C++ and the (at that time) new C++11 unsorted_map class could get better performance by having the main loop statically optimized and compiled, but decided to write the code to measure just how much faster.



To my surprise, the C++ version, using std::unsorted_map straightforwardly, release build with full optimization, was SLOWER than the C# version compiled on the same Visual Studio 2010 release by about half.



I'm pretty sure that smarter use of unsorted_map, pre-allocating the map size, and maybe some file I/O improvements, could have tilted the balance back in favor of C++, but the point is that the C# programmer didn't have to do anything special to get decent performance out of the platform.



Also, there is portability. C++ is built on C, which in turn was designed primarily for developing Unix applications. A Unix programmer's idea of portability means "portable to another Unix", and even that's not always a breeze. Take a look sometime at the things that the autoconf tool needs to do.



Java handles cross-platform portability much better. Threading and exception handling always work, for example, and no changes to compiled class files are needed. C++ has binary compatibility issues even among different compilers for the same machine.



So, there you have a number of arguments that it is C++ that is limited, compared to Java (or C#). You probably have a different idea of "limited", but we'll never know if you don't say what that idea is.
anonymous
2017-03-18 14:58:39 UTC
Why do people drive cars; when you can fit so much more in a 7.5 tonne HGV?
anonymous
2017-03-18 09:51:51 UTC
They should not only consider C++, but also Rust and Haskell. Rust is a low level systems programming language like C++, but does more error checking at compile time to make sure the program has as few bugs as possible. Haskell is a very high level language for high productivity, and makes reasonably tight code when you know what you're doing, but is harder to learn. With C++ you spend more time debugging, and that keeps it from being as productive as it should be.
Louis
2017-03-18 09:21:38 UTC
As a programer point of view, as a security level and speed of compilation, Java is better than c++.
chrisjbsc
2017-03-18 08:50:45 UTC
Ease of use and speed of programming.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...