Differences Between Java And C Essay Research

Differences Between Java And C++ Essay, Research Paper DIFFERENCES BETWEEN JAVA AND C++1 INTRODUCTION Since its release in 1995, Java has been hyped in many places, including computer magazines, broadcast news, and the Internet, as the solution to all problems in the application development community.

Differences Between Java And C++ Essay, Research Paper

DIFFERENCES BETWEEN JAVA AND C++1 INTRODUCTION Since its release in 1995, Java has been hyped in many places, including computer magazines, broadcast news, and the Internet, as the solution to all problems in the application development community. As it has only been around for approximately 4 years now, it is still emerging into the programming language market. The main area where Java has had a large impact had been on the Internet. It is widely maintained that “Java is definitely the best tool so far for writing Internet applets.” (http://www.relisoft.com/java/c_java.html) Testimony to this statement are the numerous sites on the WWW that currently use java applets.Apart from being able to create “cute” Internet applets, as yet Java has struggled to break into the area of application development. When compared to a language such as C++, java has some large advantages but also some disadvantages. In this paper I plan to discuss the differences between these languages and the merits of each.2 ADVANTAGES OF JAVA One of the attractions of Java as a programming language is that is is a purely object oriented language. This allows programmers to design reusable components easily, which can reduce development time. “You can churn out Java four or five times faster than C++” (http://www.mcmillan.com/JavaVs.htm) Another factor that can help reduce development time is its relatively simple syntax. It’s very similar to C++, making it very easy for an experienced C++ programmer to learn Java. Also it’s automatic memory management, which includes a garbage collector, negates the need to keep track of pointers or delete objects. This makes it much simpler to write and understand than C++. Another advantage Java has over other languages is its portability. When a Java program is compiled, it is not compiled into native machine code, instead it is compiled into byte code which can be interpreted by a Java Virtual Machine running on the host computer. Once a specific computer architecture has a Virtual Machine designed for it, the computer can execute any Java program that has been compiled into byte code. This portability becomes evident in web based applications. Web developers can write applications in Java, compile them once, and run them on any machine that has a Java compatible web browser. Although Java’s portability gives it a clear advantage over other languages, this feature also creates one of Java’s biggest disadvantages. 3 DISADVANTAGES OF JAVA Although Java’s ability for producing portable, architecturally neutral code is desirable, the method used to create this code is inefficient. Unlike natively compiled code, an interpreter must first translate the Java binary code into the equivalent microprocessor instruction. Obviously, this translation takes some amount of time and, no matter how small a length of time this is, it is slower than performing the same operation in machine code. On occasions where it is desirable for code to be as efficient as possible, Java’s automatic memory management may not be the best option. In languages such as C++ where memory management is done explicitly, it may be possible to speed up a program by altering the memory allocation and deletion, but this ability is taken away from us in Java. 4 DIFFERENCES BETWEEN JAVA AND C++ 4.1 Theoretical Differences4.1.1 Speed DifferencesThe difference in speed between C++ and Java is very important. Even with all of Java’s benefits, Java will not be widely excepted if it can not perform adequately. C++ has been widely adopted by developers and they will not be willing to change languages if the applications they develop with Java do not measure up to their personal and their clients standards. However, if the speed difference is negligible, developers may be willing to learn and program in Java because of the significant advantages the language offers. The introduction of just-in-time compilers for Java may have addressed some of these problems. “Just-in-time compilers have brought Java performance virtually neck-and-neck with C++” (http://www.ncworldmag.com/ncworld/ncw-01-1998/ncw-01-jperf.html).

4.1.2 Language Differences 1. In Java, everything is a class. There are no stand-alone functions. Even main() is a member function!2. In Java, everything is a reference, so the programmer must make sure that memory is allocated properly (using new!), but does not explicitly de-allocate memory.3. In Java, all arrays and objects are passed-by-reference, so a method can change any object that is passed to it.4. Java has built-in graphics capabilities, while in C++ the graphics parts of an application are vendor-specific.5. Java can be used to write both stand-alone programs (applications) and programs that can be run over the Internet by a Browser (Applets). 4.2 Physical Differences 1 Java Has No Pointers – The referencing and dereferencing of objects is handled for you automatically by Java. Java does not allow you to manipulate pointers or memory addresses of any kind: 2 Java Has No Global Variables – In Java, every field and method is declared within a class and forms part of that class. The fields and methods of a class are known as the members of a class.3 Java Does Not Support Multiple Inheritance – C++ supports multiple inheritance of method implementations from more than one superclass at a time. The Java language designers chose to avoid the added complexity by using interfaces instead. Thus, a class in Java can only inherit method implementations from a single superclass, but it can inherit method declarations from any number of interfaces4 Java Does Not Allow Operator Overloading – C++ allows you to define operators that perform arbitrary operations on instances of your class. In effect, it allows to extend the syntax of the language. After much debate, the Java language designers decided to omit such operator overloading from the language.5 Java Includes the Use of Threads – Java allows multiple execution paths to be carried out virtually simultaneously, thus providing a way to handle concurrent operations. 5 CONCLUSION There is currently a large debate going on over whether Java is all that it is cracked up to be. Some say that Java is a wonder language that will eventually support it’s own platform and leave the Windows OS in the dust. There are others that say Java not nearly as good as everyone says it is, and besides some nifty web applets, Java is not very useful.These people should bear in mind that Java is relatively new, and not too many software developers have started using it. If Java can live up to it’s potential as a truly object oriented programming language, it could change the face of computing as we know it. C++, on the other hand, has been around for a little while and is currently very integrated into the computer community. Just about everyone agrees that C++ is useful and although it may not be the best object oriented programming language out there, it is certainly here to stay.6 REFERENCES 1. Java vs C++ Viewed 15 May 1999, http://www.cs.wisc.edu/ cs368-1/SECTION/NOTES/Java-vs-C++.html2. ME Inc. Java Vs the Others Viewed 14 May 1999, http://www.mcmillan-inc.com/JavaVs.htm3. The Battle of Languages Viewed 15 May 1999, http://www.relisoft.com/java/c_java.html4. Just In Time for Java vs. C++ Viewed 13 May 1999, http://www.ncworldmag.com/ncworld/ncw-01-1998/ncw-01-jperf.html5. Eckel, Bruce. (1998) Thinking in Java. Prentice Hall Inc.