Java for Games

This is a discussion on Java for Games within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I'm pretty much expirienced with C++ and C, and all my programming skill exsist only to create games. So i ...

  1. #1
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377

    Java for Games

    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.
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    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++.

  3. #3
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    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.
    {RTFM, KISS}

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    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...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    Yeah, for text based games, QBASIC is fine.

    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.
    {RTFM, KISS}

  6. #6
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by spoon_
    Yeah, for text based games, QBASIC is fine.
    nibbles? gorilla? those were both graphical and first written in QBASIC
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  7. #7
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    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.

  8. #8
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    I'm sticking with C++ it seems that it will rule forever in game industry...
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  9. #9
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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.

  10. #10
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    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.

  11. #11
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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.
    Last edited by VirtualAce; 04-08-2006 at 02:06 AM.

  12. #12
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    Quote Originally Posted by Bubba
    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.
    Last edited by Mad_guy; 04-08-2006 at 06:31 PM.
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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.

  14. #14
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Quote Originally Posted by Bubba
    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?
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  15. #15
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by Mad_guy
    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.

    Quote Originally Posted by ahluka
    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.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Java for real-time applications
    By zacs7 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 08-26-2008, 07:34 AM
  2. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 03:06 PM
  3. The Java language is being expanded
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 06-11-2004, 10:07 PM
  4. Java woes
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-06-2003, 01:37 AM
  5. How to use Java with C++
    By Arrow Mk 84 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2003, 04:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21