Java is fast?

Started by
110 comments, last by rip-off 18 years ago
Quote:And please, no stupid comments about how performance doesnt matter, it _does_ matter if you want to do cutting edge things.


How many people have the funding, the skill set and the team to build a big game? Well, your "cutting edge things" argument falls apart even before a single line of code is written for the majority of the people here.

When people will realize there's more to software than just typing code? The industry is set the way it is right now for a variety of reasons, but don't bet it's going to stay like this forever. The same way C got good enough to replace assembly, and C++ got good enough to replace C, things may change.
Advertisement
Quote:Original post by Anonymous Poster
And please, no stupid comments about how performance doesnt matter, it _does_ matter if you want to do cutting edge things.

Java is fast enough FOR ME. 1300 fps in my current opengl tetris clone (without any optimisations in rendering yet) is fast enough FOR ME. I don't do cutting edge technology.
C replaced asm since it provided a much higher level language, while still being efficient. C++ replaces C because it provides much more abstraction than C, while still being efficient ( even more efficient in than C in some cases, like use of general methods: std::sort instead of qsort etc). Also note that none of these languages try to restrict what the programmer can do, you can still link assembly code together with your C or C++ code. You can manage your own memory, or use 3rd party libraries etc.

Java is much slower than all these languages (dont bother arguing about this until you can provide fair, non-trivial benchmarks), and it is in ways less abstract than C++. C++ allows you to create new types that you can work with in exactly the same way as the built-in types, while java forces the programmer to work with "Objects" and "primitives". This becomes very important when it comes to generic programming. In java, you cant use primitives when using generics since the generics in java are just some automatic casts under the hood (Array is the same type as Array). You cant pass primitives by reference, need to wrap them here too.

And we shouldnt forget about memory usage (good url: http://plan99.net/~mike/blog/2006/01/07/memory-and-managed-code/ , dont really know how accurate it is ) All objects in Java have atleast 12 byte or something as overhead, so your collections will consume a lot more memory in Java. A 1 million Array of 32 bit integers will have an overhead of 12mb while only storing 4mb of actual data. Java programmers will probably reply with that you should write your own custom container for this type, or perhaps use raw buffers, which just proves my point that Java isnt really that abstract in practice.

And even if I defined "cutting edge" as the last 4 years, Java would still not be efficient enough for serious stuff. If you want to use Java for your stuff, go ahead, but this thread started as one of those "C++ will die" threads that Im quite sick of.
(Array is the same type as Array) should be:

Array<Type1>
is the same type as
Array<Type2>

Quote:Original post by Anonymous Poster
Java is much slower than all these languages (dont bother arguing about this until you can provide fair, non-trivial benchmarks), and it is in ways less abstract than C++.


WHAT!? Less abstract? How being closer to the hardware is "more abstract" in your opinion?

Some people look like that are living in a city sieged by the roman army. Your high walls (the speed) won't hold forever, it never did.
Perhaps you should read what I wrote? I wrote that C++ allowed you to abstract more in some cases.
I think it's incredibly sad that people have to post anonymously to avoid getting voted down by some douche because they want to state their opinion.

Learn to make games with my SDL 2 Tutorials

Quote:Original post by C0D1F1ED
C++ translates directly to machine code, and won't add any extra overhead, just exactly the code you wrote.

This reason is enough that C++ is faster than Java even it's a little.

IMO, The relationship between C++ and Java is like char * and std::string.
I'm sure that char *, may be at least a little bit faster than std::string b/c std::string does bounds checks and what not. But you know.. it's a hell lot more convenient to use std::string than char *, and most programmers do use std::string rather char *. Stable, Reliable, Convenient....

Just a thought from a novice, so correct me if I'm wrong.

Quote:Original post by Talonius
Having a fast game is worthless if it crashes all the time. I think the games industry needs to wake up and smell the coffee. Speed is good. Reliability and stability is better.


I think the vast majority of game patches are for things that could not be solved by a language's safety features. Scripting errors seem very common, and when the game crashes it usually seems to be from driver bugs. Java will help with neither of these things (you can try convince the driver makers to use it if you like).
Quote:Original post by Anonymous Poster
Also note that none of these languages try to restrict what the programmer can do, you can still link assembly code together with your C or C++ code.

Which limits the code to a specific hardware architecture.

Quote:
Java is much slower than all these languages (dont bother arguing about this until you can provide fair, non-trivial benchmarks)

How can you be so sure? Have you read an article from 1997 stating Java is "much slower then C++"? Have you conducted your own tests? Do you even know about JIT?

I used to be against Java for game programming because of garbage collection. I though it might introduce inpredictable long pauses. Then some day I conducted tests and it turned out the pauses were less then a millisecond long. So even if the pauses were 10 times as long there would still be no way to notice them.

Most people think Java is slow because it USED TO and there's a lot of outdated performance comparisons on the web. It seems to be very hard to get these prejudices out of people's heads.

Quote:
and it is in ways less abstract than C++. C++ allows you to create new types that you can work with in exactly the same way as the built-in types, while java forces the programmer to work with "Objects" and "primitives".

That's because objects are always treated as references. It's a design philosophy. And operator overloading is evil.

Quote:
You cant pass primitives by reference, need to wrap them here too.

You rarely need this if you are a good java programmer. Why would you want to tell a method that it should tweak values which do not belong to the corresponding object? It's bad OO design.

Quote:
All objects in Java have atleast 12 byte or something as overhead

Which is a good thing because you have runtime type information. Java's reflection API is amazingly powerful.

Quote:
A 1 million Array of 32 bit integers will have an overhead of 12mb

A 32 bit integer is not an object :)
The overhead for the entire array is only 12 (or whatever) bytes.

Quote:
If you want to use Java for your stuff, go ahead, but this thread started as one of those "C++ will die" threads that Im quite sick of.

I'd be glad to see C++ die, because these types of threads in the beginners forum would cease to exist:

- what do I put in the header file, what in the .cpp file?
- my program crashes and I have no idea why (buffer overflows)
- A needs a pointer to B and B needs a pointer to A (but the poster has never heard of foreward declaration)
- all sort of stuff related to memory leaks (destructor needs to be virtual etc.)

This topic is closed to new replies.

Advertisement