1. Introduction
Java and C++ are the most used languages in programming for most of programmers and system designers. Java has a structure called an “Interface”. Java interface is almost identical to a C++ class that has nothing but pure virtual functions. Inherent in java is not efficient from more than one base class; even if the base classes have nothing but abstract methods or pure virtual functions. The differences between Java and C++ can be summarized as in Table 1.
The time needed to execute some code, algorithm, program or complete system program is considered critical in any programming language, in this paper the time needed to execute some same code in both Java and C++ is used to compare between such two languages. The minimum time needed to execution is an advantage because it reflects how much is the language is powerful and efficient. The minimum time of execution means more speed of execution which is the main goal of any designer or programmer.
Many researches and studies discussed this issue, Lutz Prechelt, (1999), discussed the relative efficiency of Java programs, in particular in comparison to well established implementation languages such as C or C++. Java is often considered very slow and memory-intensive. Most benchmarks, however compare only a single implementation of a program in, say, C++ to one implementation in Java, neglecting the possibility that alternative implementations might compare differently. In contrast, the current article presents a comparison of 40 different implementations of the same program, written by 40 different programmers. The inter-personal program differences are larger than those between the languages and the performance gap between Java and other languages is still shrinking rapidly, [1].
Peter Sestoft, 2010, they compare the numeric performance of C, C# and Java on three small cases. Managed languages such as C# and Java are easier and safer to use than traditional languages such as C or C++ when manipulating dynamic data structures, graphical user interfaces, and so on, [2]. Dirk E. et al. (2011), discussed the RC++ package simplifies integrating C++ code with R. It provides a consistent C++ class hierarchy that maps various types of R objects (vectors, matrices, functions, environments, ...) to dedicated C++ classes. Object interchange between R and C++ is managed by simple, flexible and extensible concepts which include broad support for C++ Standard Template Library idioms. C++ code can be compiled, linked and loaded on the y, or added via packages. Flexible error and exception code handling is provided. RC++ substantially lowers the barrier for programmers wanting to combine C++ code with R. [3,6].
Michi H. et al. 2012, compared between Windows Communication Foundation and Java: Remote Method Invocation which are currently seen as major contenders in the middleware space, performance is often taken as the sole evaluation criterion, despite the fact that performance is only one of many factors that influence the choice of middleware. They provided a performance and scalability comparison of the three middleware platforms, and discussed when performance and scalability matter and when they do not, including their likely impact alongside other factors on the overall cost of a project. Finally, for those applications that indeed require high performance and scalability, the article points out a few techniques you can use to get the biggest bang for your buck, [7].
2. Results and Discussion
From last comparing between Java and C++, the main thing that may reveal which software is better is the time to execute the same algorithm. So as an example consider the following Java code:
public class RealTime
{
public void Do()//must complete in 500 μs
{
Clock c = new Clock; //might collect!
// diddle with clock for 100 μs
}
}
If this code is executed using both Java and C++, Java takes 500 μs to be complete such algorithm. This is a typical constraint in a hard real time system. Those functions that call {Real Time. Do()}depend on the fact that it will take no longer than 500 μs to execute. While the same function takes just 450 micro seconds to be executed using C++. The goal of the experiment is to measure the time needed to execute the same code on both Java and C++.
Figure 1 shows a time of execution comparison between Java and C++. It is clear that C++ is faster than Java which can be represented as: