PDA

View Full Version : Java for Games



ElastoManiac
04-06-2006, 12:55 PM
I'm pretty much expirienced with C++ and C, and all my programming skill exsist only to create games.
So i started to learn Java, and i pretty much liked it. It seems logical and everything, So i'm wondering
could games be written in Java. I mean are they fast enough, I'm planning to use OpenGL with java.

And what do you think is Java better than C++. // ignore the portability
I think it's smart to invest my time in Java, I see future in it. :cool:

Dante Shamest
04-06-2006, 02:34 PM
For games? My opinion is stick with C/C++. Java is good for enterprise stuff, but for games, it's a bit slow. Oh, the Java fanbois will tell you that's not true, but in most people's experience, it is.

Don't throw Java away though, it's good for a bunch of other stuff. Amazon uses it, EBay uses it. I personally use it mainly for quick prototyping, then porting the final application to C/C++.

spoon_
04-06-2006, 03:02 PM
For simple games, Java is fine.

I wrote Tetris in about 2 days and implemented battle tetris over TCP/IP. A lot of things are happening and it runs fine on slow computers too.

major_small
04-06-2006, 04:55 PM
for simple games, QBASIC is fine.

but yeah, JAVA is inherently slower than C++. I've even noticed it in small apps... like Dante Shamest said, lots of JAVA folk will tell you otherwise, but I've never seen it... at least in a fair competition...

spoon_
04-06-2006, 05:10 PM
Yeah, for text based games, QBASIC is fine. :rolleyes:

The OP automatically limited his responses by asking a question about Java on a board mainly for C/C++. I often wonder what the hell people expect when they ask questions about Java on this board.

major_small
04-06-2006, 05:18 PM
Yeah, for text based games, QBASIC is fine. :rolleyes: nibbles? gorilla? those were both graphical and first written in QBASIC

Perspective
04-06-2006, 05:19 PM
As long as your not trying to do state of the art graphics java will be plenty fast, the C/C++ "fanboys" are just plain wrong if they say otherwise.

Using OpenGL with Java however, adds an extra layer of abstraction in addition to things like garbage collection. Performance will suffer with high end graphics, but simple things (even simple 3D things) will be fine.


Although, if you want ease of programming, and you don't mind that extra layer of abstraction, you should use python ;) They have a one-to-one binding for the OpenGL libraries.

ElastoManiac
04-06-2006, 11:42 PM
I'm sticking with C++ it seems that it will rule forever in game industry...

VirtualAce
04-07-2006, 12:00 AM
Java is a tool.

Misuse it by trying to do high-end graphics.

C++ is a tool.

Misuse it by writing code that runs as slow as Java.

okinrus
04-07-2006, 09:43 PM
So i started to learn Java, and i pretty much liked it. It seems logical and everything, So i'm wondering could games be written in Java. I mean are they fast enough, I'm planning to use OpenGL with java.

If most of the game execution is spent inside the OpenGL system, a Java game might be comparable to a C++ one. But otherwise, you'll either end up writing a porition of game code using C++ or your game will be slower than a C++ one.

VirtualAce
04-08-2006, 01:03 AM
Some of you who think a language is just more semantics, rules, etc. need to look at the assembly underneath of it all. After you learn assembly you will realize that C/C++ and assembly are very close, easy to mix, and you can do just about anything in both languages (except write bootstraps in C).

The way I see it from an assembly standpoint, I don't think you can get any closer to assembly performance wise than C/C++. The way C/C++ handles stacks, memory, pointers, objects, etc, etc. is very close to the way assembly does.

It just doesn't get any faster than C/C++ unless you use pure hand-optimized assembly (and not all asm is faster than C).

I don't see this changing and especially not from a language that has a virtual machine and even when compiled still does some odd stuff with memory and a lot of stuff behind the scenes that just slows everything down.

C/C++ for games.

And if you look at the old C libraries you will see functions like setjmp, emit, etc, etc. You can see just by looking at some of the functions and what they do that C/C++ was intended to be a language that could do anything assembly could....and for the most part it has succeeded.

I've found no other language to date that I've had a more pleasant experience with. Normally I find that when some other language tries to simplify something complex, the underlying code is too slow to be of use, and that language often does too much for you resulting in a loss of control.

Mad_guy
04-08-2006, 10:52 AM
Some of you who think a language is just more semantics, rules, etc. need to look at the assembly underneath of it all. After you learn assembly you will realize that C/C++ and assembly are very close, easy to mix, and you can do just about anything in both languages (except write bootstraps in C).

The way I see it from an assembly standpoint, I don't think you can get any closer to assembly performance wise than C/C++. The way C/C++ handles stacks, memory, pointers, objects, etc, etc. is very close to the way assembly does.
The reason they 'handle' things the same way is only due to how the compiler implements it, and as it stands now, most compiler creation follows a rather orthodox pattern in terms of how things like stacks and registers are handled. I could write a compiler that implemented things in ridiculously ........ed up ways if I wanted.

When you're in C, you need to divorce the actual implementation of the program from the lower levels. There's no such thing as a stack in C unless you're talking about a linked list, or you're just unashamedly technical all the time.


It just doesn't get any faster than C/C++ unless you use pure hand-optimized assembly (and not all asm is faster than C).
This doesn't make sense. A quicksort implementation will virtually always be faster and more efficient than a bubblesort, regardless if I program the Quicksort in Java and the Bubblesort in C.


I don't see this changing and especially not from a language that has a virtual machine and even when compiled still does some odd stuff with memory and a lot of stuff behind the scenes that just slows everything down.
Many times, it's not the compiler nor the virtual machine that causes the bottleneck. My friend had to write a java program to solve the n-queens problem for college, and while his algorithm was virtually the exact same, the person who had the second highest grade (he 'won' if you think of it that way,) his implementation was over twice as slow. What's the solution? That parts of the language could be constructed badly, he rewrote parts of Java's libraries and then implemented n-queens, and when he ported it to C and even Assembly, the speed difference was only a measily %15 difference, this was before Java even HAD a just in time compiler.

While I may be playing devil's advocate here, the thought of this occuring in C or C++ isn't insane. Using some of GNU's profiling tools, many people noticed huge problems with the STL library implementation in C++ (I believe it was vector or something.)

Another problem for the bottleneck is just the system itself, it's unfair to say "java is just slower," in many circumstances, it's not at all unusual for Java to be faster than C or C++. If I'm running a copy of IDA Pro and disassembling ntoskrnl.exe on a box with 128mb RAM on windows 2000 the chances of other programs, regardless of their language seeming slow is high (I would know, I've done it.)



And if you look at the old C libraries you will see functions like setjmp, emit, etc, etc. You can see just by looking at some of the functions and what they do that C/C++ was intended to be a language that could do anything assembly could....and for the most part it has succeeded.
There's some things that I can't do in C that I have to handle with assembly, even if it is only inline assembly or a linked procedure from doing 'nasm -fwin32 test.asm', there are some things I just flat out cannot do in C or C++ natively. There's plenty of practical reason to use assembly these days, if you're going into a security profession and don't know assembly but only know C, you're already a joke.


I've found no other language to date that I've had a more pleasant experience with. Normally I find that when some other language tries to simplify something complex, the underlying code is too slow to be of use, and that language often does too much for you resulting in a loss of control.
Well, everybody has their own experiances and preferences with programming languages I suppose.

VirtualAce
04-08-2006, 07:41 PM
There's some things that I can't do in C that I have to handle with assembly, even if it is only inline assembly or a linked procedure from doing 'nasm -fwin32 test.asm', there are some things I just flat out cannot do in C or C++ natively.


Um...ok but isn't that what I just pointed out? You Java-ites surprise the hell out of me and why people ask about Java on a C board is beyond me. I've never seen any game in Java run faster than C/C++ unless of course the programmer is like most noobs on this board and use an (N^256) loop to perform even simple tasks.

Any language can be slow, but natively and when coded/used correctly - nothing is faster than C/C++ - besides pure asm or asm implemented in circuits - thus hardware.

Nothing. So you can have your coffee beans.

cboard_member
04-09-2006, 01:39 AM
Um...ok but isn't that what I just pointed out? You Java-ites surprise the hell out of me and why people ask about Java on a C board is beyond me. I've never seen any game in Java run faster than C/C++ unless of course the programmer is like most noobs on this board and use an (N^256) loop to perform even simple tasks.

Any language can be slow, but natively and when coded/used correctly - nothing is faster than C/C++ - besides pure asm or asm implemented in circuits - thus hardware.

Nothing. So you can have your coffee beans.

What is (N^256)? You talking about O(N^256)? I was reading about asymptotic analysis the other day (thanks Prelude) - what does the '^' mean?

Quantum1024
04-09-2006, 02:12 AM
This doesn't make sense. A quicksort implementation will virtually always be faster and more efficient than a bubblesort, regardless if I program the Quicksort in Java and the Bubblesort in C.
While chossing the right algorytham has an affect on speed this dosen't negate the affect of language.


and when he ported it to C and even Assembly, the speed difference was only a measily %15 difference, this was before Java even HAD a just in time compiler.
15% Is a lot if applied to a routine that will be called thousands of times.


If I'm running a copy of IDA Pro and disassembling ntoskrnl.exe on a box with 128mb RAM on windows 2000 the chances of other programs, regardless of their language seeming slow is high (I would know, I've done it.)
This dosen't have anything to do with one language being inherently faster then another. If you're going to get your machine into a state where nothing will run at an acceptable speed then maybe it dosen't matter what you coded your program in but when you want to play a game you shouldn't be running anything resource intensive.


What is (N^256)? You talking about O(N^256)? I was reading about asymptotic analysis the other day (thanks Prelude) - what does the '^' mean?
The ^ symbol means to the power of.

prog-bman
04-09-2006, 12:24 PM
From Somewhere(I think entropysink).

Arguing on the Internet is like running in the special Olympics, even if you win you are still retarded*.


*Sorry if you are offended

VirtualAce
04-09-2006, 05:48 PM
Ok so we are retarded.

But I think asking about Java continuously on a C/C++ board is moreso.

Magos
04-10-2006, 11:16 AM
noobs

Oh god, someone please criminalize usage of this word now!

VirtualAce
04-10-2006, 10:59 PM
No cuz it fits.