View Single Post
Go4Expert Member
31Jan2008,12:32  
oleber's Avatar
Off course?

Depends on the problem that you are using.
Try to use allot of:
- multiple derivation with virtual methods
- allocation and free memory
you can get a surprise with the newest version of Java.

Java was slow in the first version, really slow. but now is really comparable. It has the advantage and the disadvantage of having a VM.
What does the VM for you:
- moves your most frequently used object to the some blokes in memory, such a way that you will get them frequently in cache. Of course you can do it in C++, but who does that?
- Optimizes the code in run time, this optimization can't be done without statistics. This reduces the jumps. Your C++ compiler doesn't do it.
- From the version 1.6 your object can be allocated in the stack and you just need to do your normal code. Before this was a cancer in Java since you where always going to the heap.

So the point is: It's not clear if C++ is always faster then Java, most of the time C++ loses if you are really programming in OO way. Of course that C is faster then Java, but C is also faster then C++.

Now Java have it's problems. In average is fast, but can slow down times to times with the Garbage Collector, code optimizing, ... It isn't good for realtime systems, for that you have the serious realtime language like ADA. Clearly better suit ball than C++ for this systems, the problem is the small community and the very expansive compilers.


Please do some tests with the new version of Java, maybe you can get a surprise.