Jos Timanta Tarigan wrote: > the concept of java being slower than C++ must be fixed. imho java is also > built under C so it should be as fast as C or C++. according to my > experience, what makes java 'looks slow' is the thing called Garbage > Collector. its a blessing yet a curse. we 'dont' have to do memory allocation > but in return the vm must do memory cleanup once in a while. the 'slow' part > is when the memory cleanup take action. > > i've tried to do a simple but mass collision detection in java and its > annoyingly slow in a certain time (when the garbage collector do the > cleaning), but damn fast at the rest of it.
As Thomas said, the only tests most people do are trivial and small: e.g. doing something simple and looping a zillion times. That is not accurate. All it does is compare loop optimization between compilers. The best way to compare would be to develop a medium-sized application in both languages that does the same thing. The problem is that the languages enable and encourage different designs, or the same design implemented in different ways. Inheritance is implemented differently in both languages, as is any sort of dynamic code loading. In C++ you have to have headers, but you might load a module at runtime: regardless, it is strongly-typed. Java allows dynamic class loading via reflection, which is incredibly slow by comparison (although more powerful). From personal experience with thick-client applications, C and C++ tend to load the fastest, C# and Java are slower. once the application is loaded into memory and all the data is cached as necessary, there is little to no difference between any of the languages. Keep in mind that a bad programmer will make ANY language perform poorly. -- John Gaughan http://www.jtgprogramming.org/
