Home Page | Submit an Essay | Links Description of this essay : Compares java and C++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.
We Will Write a Custom Essay Specifically
For You For Only $13.90/page!
“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. 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.
1 Theoretical Differences 4.1.1 Speed Differences The 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). 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