Archived

This topic is now archived and is closed to further replies.

Robininni

How bout... Java?!

Recommended Posts

Hi gang! I am currently studying Java independently (not in CS degree or anything) and I am wondering if you enlightened ones could help me out with a few generalized questions. I realize that most retail games are created using C or C++ and I have heard talk that Java has some disadvantages for game construction (well in some genres) because the code is interpreted by the Java Virtual Machine (isn''t that what causes the execution "speed" problem??). Well anyway, here are my questions for those of you kind enough to post a response: 1) After learning java and becoming "proficient" in it''s use, will "picking up" C/C++ be fairly easy? I have heard this, or the opposite, actually--picking up Java is simple for a C/C++ programmer. 2) What, if anything, is wrong with game creation using Java? What, if any, genres are great to produce with Java and what, if any, genres are poor performers using Java? 3) (For you very experienced industry professionals) What do you forsee the future bringing for the use of Java as a viable game development platform, or will it ever, if not already, be one? 4) How many chucks could a wood-chuck chuck... okay, just making sure you were paying attention... 5) Am I wasting my time learning Java if I want to learn to program games in addition to general application software? Thank you so much for your responses. -Rob --> "Go sell crazy somewhere else, we''re all stocked up here!"

Share this post


Link to post
Share on other sites
Java: I absolutely hate the language with an undying passion. Hope I don''t offend anyone saying that, but it''s just my personal opinion. Now that we got that out of the way, java CAN be used for game development. You can write many simple games that will run just fine on any half way respectable machine. If using AWT (can''t remember what it stands for), you can get some pretty simple graphics much easier than in C/C++. Once you get the hang of actually programming games, switching over to c/c++ won''t be too much work. You will have to learn how to create windows with a library such as win32, mfc, qT, GTK, or many many others. You can do simple graphics with these, but if you want to get into some advanced stuff, like 3d graphics, you will have to learn DirectX or OpenGL. OpenGL is available in Java but I''m pretty sure it''s more work, and it will never run as fast as C/C++ code. And yes, your right, the JVM does slow down your code alot, as does bounds checking and garbage collection.

Share this post


Link to post
Share on other sites
1) Java has some features that can make learning C/C++ more difficult if you don''t understand what is going on under the hood. One such feature is garbage collection.

2) The main problem with games in java is that it is generally slow. It is possible to make fast applications in Java, but very few people take the time to do so. It will almost always be slower than good C/C++ code, but in many cases it is fast enough. It doesn''t matter what genre the game is, what matters is how complex it is and how fast or slow the algorithms you use are.

3) I''m not an experienced industry professional, but I see .Net replacing Java once it becomes cross platform (if it does) because it seems to run much faster and from what I hear, it isn''t really any more difficult (many people even claim it is easier).

4) 73

5) Opinion widely varies on Java''s fitness for general application development. Many people say it is fast enough for most things, but in my experience, GUI programs written in java are very very slow. I''ve seen many, many applications written in java that take ~2+ seconds to redraw a simple GUI (ie no custom controls, just standard buttons, combo boxes, etc) and IMO that is way too long when my C++ program can have the same kind of GUI drawn without me even noticing that it had to redraw it. If you need the ease of java, I hear the .Net framework is just as easy/easier to use and all the programs written in .Net that I''ve seen are many times faster than Java programs.

Share this post


Link to post
Share on other sites
In response to Extrarius: I was at a microsoft convention last week, and in one of the demonstrations they wrote, compiled, and ran a web service under FreeBSD, then copied the executable over to windows, and ran it without compiling it. After seeing that, I have decided to write my current game using .NET and OpenGL. I find .NET increadably easy to use, but that is compared to what I went through learning COM, DirectX, and win32. Don''t get me wrong, I''m not a Microsoft Zealot, if I find a technology I like, I use it. End of story. They also mailed every one there a free copy of Visual Studio .NET Academic. (Major brownie points :D). Still waiting for mine impatiantly. But whatever you choose good luck. My advice: Just try playing around with as many different things as you can. Eventually you will find something that clicks.

Share this post


Link to post
Share on other sites
I take it the lot of you have not used java in the last three years or so. Java code is as slow as you make it, just like c.

1 - Java is slightly easier for a beginner to pick up. I went from c to java without any difficulty, I doubt it would be hard going the other direction.

2 - There is nothing wrong with using java for game creation. There are limitations with the current jre's that you would have to work around. Java is a young language and in general a native program will run faster than one in a jre. That said every year that goes by the jres get closer to c and in some cases programs can run faster in a jre than its c counterpart. You are not going to make the lastest and greatest first person shooter in java right now. In a year or two that situation may change. Any other type of game that isn't dependant on 200fps is going t owork just fine. Plus the time you will save in development by not having to chase down memory leaks or bad pointer arithmatic will mean your game gets done faster.

3 - Java has already been in several comercial games and will be in more in the future. It will probably take off quickest in the cellphone/pda market. Many new cellphones will include hardware to accelerate java programs. Sony is currently working with Sun on a gaming initiative, though there has been an information embargo for some time and I have no idea how far they are along. Check out LWJGL and Javagaming. Hopefully this initiative will result in a gaming jvm or a way to tune the current jvm to work better with games, like limiting the garbage collection to video blanks. Though if you don't create garbage in the first place, which you probably are not doing in c either, the garbage collector doesn't run.

5 - No.

"... we should have such an empire for liberty as she has never surveyed since the creation ..."
Thomas Jefferson

[edited by - GKW on March 18, 2003 12:49:24 AM]

Share this post


Link to post
Share on other sites
Some of the statements in this thread are repeated often, and aren''t 100% correct. Java isn''t inherently slower than C++ in almost all cases. However, some parts of the Standard distribution don''t perform as well as their C++ equivalents. But in these cases there are workarounds. If Swing is too slow for you, try SWT for performance on par with Win32. If you''re getting Garbage Collection pauses, create all your objects at startup time and reuse them instead of creating objects in the rendering loop. If AWT can''t supply the graphics you want, use an OpenGL wrapper like LWJGL. The point is that the Standard Java Distribution oftentime supplies an option that may not meet your performance requirements, but you aren''t forced to use it. There are plenty of people at javagaming.org that believe that Java is perfectly suitable for game development. I should point out that there ARE some aspects of the language that negatively affect performance (memory usage, bounds checking), but these are trivial for the games that 99% of people write.

Share this post


Link to post
Share on other sites