Question:
Why is Java language preferred to C++ and Visual C++ languages?
anonymous
1970-01-01 00:00:00 UTC
Why is Java language preferred to C++ and Visual C++ languages?
Four answers:
Paul
2009-09-23 06:22:53 UTC
Java is only "preferred" over C/C++ in some application areas. There are many application areas where Java would not be an appropriate choice.
anonymous
2016-04-03 19:07:34 UTC
There is no absolute, universal 'easiest' language. Some are easy for some people to learn but not so easy for others, and vice versa. Python is one of the easiest to learn and highly recommended for beginners. BASIC is also fairly easy to learn, but some people believe BASIC teaches programmers bad habits and should thus be avoided; I'm undecided on that myself. Pascal is about the same as BASIC, at least based on what I remember from my short fling with it. C is a little more difficult (but nice and powerful), and C++ is a little more difficult than that (OOP can be ugly to learn for a beginner). Some flavor of assembly might be considered 'most difficult,' but it's really just time-consuming to code in. You also have to be very careful about using your data in its proper context, otherwise you can get wildly unpredictable results (some are just wrong while others can corrupt other data or even crash your system). I actually prefer assembly because it removes all the abstraction other languages introduce. I can handle thinking procedurally better than an OOP approach. You could also do programming with a hex editor, if you are so inclined. That would probably be the most difficult approach short of using binary. To do that you'd probably have to write your own compiler/assembler, and you'd have to have either an excellent memory or a very thorough yet well organized reference manual.
Stu V
2009-09-23 05:38:45 UTC
I guess the main reason Java would be preferred to c++ is that it is open source. Also it's much easier to code then c++. There are a lot of answers to your question although I don't know c++ enough to confidently give out detailed reasons.



What I do know is how to get a java compiler:



Eclipse (personal favorite):

http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/R/eclipse-jee-galileo-win32.zip



JCreator:

http://www.jcreator.com/download.htm
rwid
2009-09-23 10:26:28 UTC
First, where to find a Java compiler. Sun Microsystems is the premier source. The Java Developers Kit (JDK) is free for download at http://java.sun.com/javase/downloads/

If you need an entire development environment, Eclipse.org or the Netbeans IDE (http://www.netbeans.org/downloads/) are worth the effort.



I've developed in both C++ and Java for many years (actually decades). They are both good tools and each has its strengths. C++ is more complex than some other programming languages; the ISO standard itself is 310 pages long. Because of its large feature set, it is difficult to fully master C++. The main advantages of C++ are speed of execution and tighter control over the machine. If those factors aren't paramont, then Java may win by default. For instance, professional games are almost always C/C++ based applications since performance and control are important to meet consumer demands.



Java is a much newer language and was designed with many advanced features from the start. For instance, C++ has its roots in C but has evolved greatly over the years. Both Java and C++ are object-oriented. However, C++ critics cite the ability of C++ to mix styles and programming disciplines rather than enforce a single style. By sheer numbers, Java has a much larger base of knowledgable developers than C++; by this alone, Java could be considered more popular and thereby preferred. In a manner of speaking, Java brought object-orientation to the masses and this has helped speed the productive development of software.



For business, Java is preferred over C++ (depending on the industry and purpose). At its root, Java is much simpler even though it has grown considerably over the years. Java is easier to parse and actually enables more advanced tools for analysis, refactoring, etc. Java is generally easier to learn and is regarded as more productive for most business purposes. It can also be more difficult to find skilled C++ workers than those with decent Java experience.



Java is also superior with cross-platform support, architecture neutrality and portability. While it is possible to write C++ to be portable, it takes considerable effort, skill and testing to pull it off successfully. If anything, small tweaks to Java code are usually all that is needed to support multiple environments. Even bytecode compatibility works fairly well with Java's runtime environment. This enables Java to run without change in Internet browsers worldwide. C++ can't claim this ability. Java bytecode can run in embedded systems, such as, cell phones. Java also has some built-in security features.



Before the hotspot/JIT compiler, Java was considered too slow to compete with C/C++ applications. At that time, Java was targeted at the desktop or GUI frontend. The hotspot compiler now narrows C++'s speed advantage enough that business is much less concerned. In fact, Java performs well enough now that server-side computing is often ruled by Java (J2EE) application servers. Clusters of computer servers (even running with different OSes and/or virtualization) can work seamlessly together to execute the same programs or protocol compatible Java applications. Interoperability has always been difficult to accomplish soley with C++ (though web services and C++ third-party libraries have finally made inroads); CORBA was the only thing C++ had going for some time but it generally sucked in the real world. Built-in threads have also contributed to Java's responsiveness.



Java offers far more workable options for system interoperability. Therefore, Java quickly finds a home where scalability becomes important. Sometimes, it is cheaper to get something to run faster or support more users by simply adding another (physical or logical) box. If things are architected properly, just throwing more resources at the trouble spot can solve a performance problem; business often likes this situation where additional money can actually take care of an issue if only to buy time until a better solution is in place. This often wasn't the case with C++ applications mostly due to interoperability constraints and architectures lacking flexibility.



More specific to the language, pointers in C have always been a debugging challenge for developers. Since C++ includes C as a subset, many of its issues continue to plague. Java avoided the use of pointers all together and insisted upon garbage collection/automatic memory management for its primary use of memory. By design, this simplified developers' mastery of Java and avoided the source of many C/C++ troubles.


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