[java] Why, when, and how?

Started by
7 comments, last by flynboy 24 years, 3 months ago
Okay, first off I am not trying to start a flame/language war, I just wanted your thoughts. So.... 1. Why would you use Java for game development? Basically, what advantage(s) does java have over other languages? I understand the multi-platform issue, but don''t you take a large performance hit? 2. In what situations would Java be beneficial (tools? server programming?) 3. What are some good tools for Java development? Again, I''m not cutting on Java, I''ve just heard a lot of hype and do not know anyone who does any Java development. Thanks, Joe
Joe
-flynboy
Advertisement
For me, I enjoyed being able to play Java games when you couldn't download anything else on the computers at my school. Because of this I would want the ability to get as many people to play a game made by me as possible. In my programming class in high school good Java games spread very quickly through word-of-mouth. So, if my game was a good one people would learn about it quickly. Sure, the genre of your game will be limited by performance, but who said games had to be cutting edge to be enjoyed. So, as a result Java games shouldn't try to pretend that they can do something they cannot. So what? you might be asking yourselves? I just think that the Java games are a wide open territory, and I would like to be near the forefront doing things that make people say, "Is that Java?" That's all
To answer question 3, I believe that most Java games currently don't have much in the way of interface, so you could do without visual java environments (JBuilder, J++). As a result, just download the latest jdk and check for books in your library--the one I learned from actually had the CD still inside (which I returned to the library, BTW ). If there isn't a Java book or library around, searching on-line is a good place (sorry no links ).
Question 2 sounds like your already assuming the answer to Question 1 is that Java can't be a game platform, so I'll answer these in a bundle (in addition to what I've said above). Sure people have found ways to 'integrate' Java into their cutting-edge games through scripting languages and such, but what I am trying to say here is that the whole idea is not to try to make Java do something that it can't. So, it comes down to this: If you're doing a cutting-edge app then Java will have to take a lesser role in your game engine, however if you aren't doing a cutting-edge app then you can use Java and take advantage of a whole ton of people being able to play your game (Whoah, check that run-on sentence ).

Edited by - joeG on 1/13/00 2:35:39 PM
joeG
I first have to add one statement about Java:
Java is both a language and a platform. They are closely related but you can use one without the other.

Java can be compiled to x86 byte-code (or MIPS or whatever) and you can compile C to Java byte-code. There''s even a Java assembly language.

Java can even be compiled to the assembly language of the Palm PDAs.

To get to your questions:
1. The Java VM does impose a performance hit, but it remains that you can use Just-in-time compiling on many platforms to alleviate (though not really eliminate) the performance drawback (JIT can speed up your program by a factor of 20 or so). But if you compile your Java code to the target object code, no performance hit.

Java as a language is clean, strongly typed, object oriented and has a beautiful network API. All strong recommendations for game programming. Compile it to your target machine''s object code and it''s really not very different from programming in C++.

Currently in the works are the Java 2d and 3d APIs which will interface more closely to the low level hardware for high performance graphics.

2. Java is great for network programming and in embedded systems.

3. Tools for Java programming I like: notepad and the JDK.
Oh yeah, forgot to mention that I used Programmer''s File Editor. PFE inludes a lot of cool options (like capturing DOS box output--for those huge 50-compiler errors ) and has a good set of text editing options. I''m sure that there''s a better one out (PFE is like 5 years old I believe), and I''d give anyone else''s suggestion a try just to be nice and as long as its free!
joeG
A few additional things:

OpenGL is available for Java, if you don''t like to wait for the Java3D api to be finalized (personally, I for one, do not understand why we need another 3D API).

If your target is windows, the whole DirectX package is available from MS too. (What''s the use you may ask, since platform independence goes down the drain? Well, Java is a FAR better languange than C++ (i use both, and the more I do, the more I begin to hate C++)).

If you really need that last touch of performance (which you do, if you are building a "quake killer" ) you can interface to std. dll''s from Java. I.e. create a small DLL with the functions you really need optimal performance for (1% of the game ??) written in assembler, and code the rest in Java.

/Niels


<b>/NJ</b>
<b>/NJ</b>
Oh, and I forgot too:

I use VJ++ (Despite of what people say, it DOES generate 100% pure Java and it integrates to sourcesafe (which I couldn''t live without) )...

Regarding "visual" environments (as in drag''n''drop GUI editing: STUFF IT! All the tools I''ve seen for this suck big time, and it is not what you need for games development anyhow (be that C++, Java or whatever) .. If you need to "drag" your programs to make it work, use VB).

/Niels
<b>/NJ</b>
I use Java Workshop 3, because it''s simply and effective (No GUI dev), I can also change my JDK when ever I want unlike in some of the Micro$oft products. Also Sym''s Visual Cafe for Java is the best for professional use. Also one weakness is that you can''t compile straight to exes, without commercial programs...=(. New one of the Linuxs has VERY fast VM (+30% speed to older version) it means that you can build almost as fast as C++ games to Linux, only Linux, doh.
The reasons to use Java for game development mirror the reasons it is used over C++ in typical application development...

- Very flexible
- Automatic garbage collection and lack of pointers ease debugging
- Strong object-oriented capabilities
- Higher developer productivity
- etc...

I think you will find it takes much less effort to develop a game in Java than in C++ or C.

Performance is a complicated topic. There are a number of native code bindings to various multimedia APIs that allow games developed in Java to have competetive performance to those developed in C++ (DirectX COM bindings for the Microsoft JVM, Open GL bindings, Java 3D API, Gamestep Library, etc...). As has been mentioned in previous posts there are also native compilation and JIT technology to take advantage of.

Even with all that said, you will still probably find that various Java implementations will not offer the same performance one can achieve from highly optimized C++ or C code (Bindings to native libraries usually incur some over head).

For many games Java performance should be more than adequate (particularly for amateur efforts such as my own). It depends on your particular game which is more important - getting the most speed you can squeeze out of your code with C++ or the ease of use and time savings you will get from Java.

I use JBuilder 3 myself (simply because its the tool we use at work so I am familiar with it).

An aside: Java 3D is a higher level wrapper that executes on top of OpenGL or DirectX. It provides abstractions that make it easier to develop 3D content (through scene graph structures) versus making calls into the lower level OpenGL or DirectX API''s. It has default implementations for many of the tasks one would have to program in a game engine, such as collision detection and input handling. I can tell you from my own experience though that the API has a lot of growing to do.
I''m surprised to see that nobody mentioned what I think is one of the most profound reasons to move game development (and all future development in my opinion) to Java. It''s futureproof...

As it stands today, running ''The Secret of Monkey Island'' or ''Doom'' on a machine can be an exercise in frustration (after all, what hardware manufacturers worry about Adlib and Soundblaster compatability anymore). They are still great games but the platform that they run on is changing to the point that they can no longer run on it. So unless Origin takes the time to port ''Ultima VII'' to DirectX good luck playing it. With Java however, we''ve got a language that was designed from day one to run on emulators. I would say that there is an excellent chance that 10 years from now I would have no problem at all firing up a game I write today on the desktop of RedHat Linux 2010 and finding that it works perfectly.

Now, I know that there will be people (and even companies) who will try to build DOS/PC emulators that will run _some_ of these games. But anyone who has spent any time with the various game emulators out there can tell you what that experience is like. Some titles work perfectly and others won''t work at all or have bizarre quirks.

That is why I think Java is the future of game development, just as I thought Windows was the future even before DirectX first shipped. <-- That''s my, "I predicted the future before, I can do it again," line.

This topic is closed to new replies.

Advertisement