Java - Too Slow?

Many people say that Java is slow. It is slower that C++, but by how much? Does anyone know how the speeds of those two languages compare? I've heard opinions both ways: its too slow, its fine, ect.



                  -Gibi }:-@

Well, in a perfect world Java would always be slower than C++, but alas this is not a perfect world.



Having a virtual machine does push some baggage on Java that C++ doesn't have, howerver, being that Java manages many facets of optimization for you in many cases Java code can run faster than C++ code because C++ coders are often using less efficient code than the core of what Java offers.  Consider that the core of Java is used by everyone in the Java community whereas C++ APIs even the large ones are only utilized by a percentage of the C++ userbase. In addition, C++ allows you many optimizations that you can do directly, but often that also causes you to be less efficient because the power is in your hand. Java manages much of this for you and keeps you safe from yourself.



Granted there are examples of many things that can run faster in C++ but as fast as machines are these days and if you are writing efficient code in Java you can accomplish far more in less time so I think the trade-offs are worthwhile.



Finally, Java in continually being updated to be faster and more efficient whereas your C++ code is always gonna be as dog slow (my grandad always says that…I love it) as it always has been. It's called "hope from the outside".  When your code sucks at least you have some hope that one of your dependencies will get better and make it suck less. :wink:

Thanks. That was sorta what I thought, but I wasnt sure.



By the way, I'm sure that this community is perfectly objective and is not biased toward java at all. Just because it uses java and not C++… :smiley:



                  -Gibi }:-@

I'm the only one that's totally biased…everyone is moderately innocent of such accusations. 

theres one more point for java,

apps deploy nicer.



you have at least this choices:


  • applets
  • java web start
  • executable jar
  • compile it into a native executable without vm (excelsior jet, gcj)

and one more, even if it's restating the obvious:



your game will not only run windows. we crazy linux users and those strange mac guys will love you for that. :slight_smile:



yes, it's possible to develop crossplatform games in c/c++ quite easily, the tools are widely available, but somehow noone seems to use them. and you still will have to compile it for every platform.