Sign in to follow this  
killingdjef

Java for game development?

Recommended Posts

killingdjef    122
Hi, Recently I've dived into the wonderfull world of game development on indie level and was wondering some things. Initially I'd planned on learning how to do things with Java (since I have some background in Java), but I'm not entirely convinced Java is the best choice for this. Now my question is, how does java compare to languages like C# and C++ with regards to game development and how widely is it used? Generally im trying to find out if it's wise to stick with Java when it comes to game development. A quick search in the game engine index returned jME (www.jmonkeyengine.com) as best game engine and I must say that I am impressed. With such capabilities why wouldn't people want to use Java? kind regards, Jef

Share this post


Link to post
Share on other sites
Jockel    144
If you have a background in Java just stick to it. Who cares in which language you implement a cool game? The algorithms are the same.
Maybe interesting for you: http://www.bytonic.de/html/jake2.html

For the question why people don't want to use Java: maybe because they already have some source done in another language which they can reuse, maybe because their knowledge is more broaden in another language, maybe because everyone is using another language, maybe there are more examples in other languages, and so on.

But believe me, Java is just fine (as maybe almost any other language).

Share this post


Link to post
Share on other sites
Fred304    382
Quote:
Original post by killingdjef
With such capabilities why wouldn't people want to use Java?

Because a lot of people judge java's performance based on how it used to be 10 years ago.

Share this post


Link to post
Share on other sites
JWalsh    498
killingdjef,

I would advise against using Java unless you have a particular interest in web games or cell phone games. Why do you ask? Well, because historically that's the only place Java games are used. Additionally, there is a performance difference between Java and C# (C# is 2 to 6 times faster )and especially between Java and C++ (C++ is generally 10 times faster).

If you're interested in a Java-style language you might look at C#. Its a managed language and has all the benefits of Java, in addition to which it has really nice reflection, which can be useful for dynamic coding (a replacement for scripting). C# has DirectX bindings (does java?) so you have access to powerful, hardware accelerated graphics. And finally, C# is already making its way into the game development industry as the primary language for Tool development and to some degree game development.

As an overview...
Java is STILL slower than C++ or C#. You can verify that HERE.
Java isnt used on XBox, Xbox360, or PS2 (though neither is C#)
Java isnt used on (most) commercial PC games unless they're web apps.

Learn either C# or C++...as that is what most industry professionals are using these days.

Cheers and good luck!

Share this post


Link to post
Share on other sites
smitty1276    560
You can target the XB and PS2 with C#?

EDIT: jwalsh, that "Shootout" you linked to is more than 3 years old, at the least. It can hardly be useful as a benchmark. I think you made Fred's point. They didn't even use JIT java.

Share this post


Link to post
Share on other sites
JWalsh    498
smitty1276: Where do you get that it is 3 years old?

According to the website the benchmarks were done with:

Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
Microsoft (R) Visual C# .NET Compiler version 7.00.9466

Unless I'm mistaken those are both 1-2 years old...and even if Java has improved in performance...so has C# and C++ (.NET 2005), unless you're stating that only Java improves in performance over time?

But even if it were 3 years old? Has Java gotten 10 times faster in 3 years? Or are Java games popping up on all consoles? Or perhaps World of Warcraft, GuildWars, Lineage 2, EQ 2, Or ANY other game you find in EB-Games were developed with Java?

Here's a "shootout" for you, perhaps thousands of video games released in the last 3 years...how many of them were Java games....Zero?

The point is the same. The best test of a market trend is to see what the market is doing. Sure, you could argue that "Java is just as good as C#"....but WHY? Would YOU knock on blizzard's door saying "Let me be a game programmer...I know JAVA!" They would politely say "Thanks, but we dont use Java...no one does."

Share this post


Link to post
Share on other sites
Aldacron    4544
To help with your decision, check out some of these Java games:

Tribal Trouble
Puzzle Pirates
Wurm Online

Another great example is Puppy Games. They have some great shooters developed with Java. And if you spend some time at javagaming.org you'll find several others using Java to develop games.

You'll hear a lot of comments like those from jwalsh. He's right that there aren't any Java VMs on consoles yet. But that only matters to people who are developing games for the console market. Generally, that camp does not include indies and hobbyists. He's just dead wrong about the other two points he made. There are several commercial titles out there using Java. Aside from the games I listed aboce, you can find some in the retail space as well. There were a couple of Law & Order games in Java, Red Storm Entertainment used Java for some of their titles, there was a flight Sim coded in Java, and more. Google will help there. Or the games section at java.com. As for the speed point, this whole "java is slow" mantra is old hat. Just ignore it.

If the games I linked above don't prove that Java is a legitimate option I don't know what will. Maybe sales stats for the first year after Tribal Trouble's release? Maybe the fact that UbiSoft picked up PuzzlePirates for distribution in the retail space? Maybe the fact that NCSoft hired two of the developers of the JMonkeyEngine to work on an as yet unannounced project?

I recently wrote a blog entry about choosing a language for game development. I wrote it because people ask questions like this all of the time on these forums. The problem with asking here is that the forum visitors come from diverse backgrounds. Everyone has their favorite languages and are quick to spread misinformation about those they don't use. Really, if someone has never taken the time to really learn a language, then how can they have an informed opinion of it? Most people just parrot what they have hear others say.

The advice I give in my blog post is to avoid asking for language advice in general forums like this. If you want to ask others about the strengths and weaknesses of a language, the best people to ask are the ones who use it. Don't ask them to compare languages. Comparisons will usually result in biased answers and more parroting. Ask Java programmers what they like or don't like about Java. Ask C# programmers about C#. Ask C++ programmers about C++. The answers you get then will be more informed and you will be better able to use their opinions to help you in your decision.

Of course, it's always good to experiment yourself. The more languages you know, the better. But when just starting out to learn game development, it's best to stick with a language you are already familiar with. Learning game dev is hard enough. You don't need to overload yourself with learning a new language at the same time. Once you have the basics and know how to apply the concepts at a high level (i.e. in a language agnostic way), then is the time to start applying those concepts to new languages. Game development concepts don't change from language to language, only the implementation. When it comes time to go commercial, then the language choice becomes important based upon target platform, target market, available tools, and so on.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
jwalsh: what in the world? you think "Let me be a game programmer...I know C#!" would work well?? a)that would be the worst interview pitch ever. b)no one uses c# either...except for production tools! exactly where they use java as well.

overall, you win the prize for attempting to start yet another pointless flamefest. the main problem is, every criticism you have of java fits perfectly on c# as well. if pros still can't bear to use STL cause of not deterministic memory use, guess which languages they are *never going to use* for released products. go on, i'll wait. take a guess.




killingdjef: every advantage he listed for C# java has as well (though you'll have to stick to opengl...no problem, many people prefer it (and it works better if you need mac/linux compatability)). moreover, since it sounds like youre just starting off, either language should be pretty quick to get going. if you have experience in java go ahead and use that, plenty of hobbyists use it, even for major projects (jME is one, check out the lwjgl and java game development forums for some more great communities).

if you think youre going to use a lot of premade gui stuff (buttons, forms, etc) you might consider C#, as its UI system is a lot faster to get going and faster to run. if you're going to be doing straight graphics (either to a provided graphics object or with an API like opengl or directx), either language will do.

overall you had the right instinct. java will most likely not be included in a major game any time in the near future...its mostly used by indie projects and as a scripting language for the big boys). developers tend to have large c and c++ codebases, use other peoples engines, or are just plain resistant to change (see above thread...no offence to dave eberly, he's perfectly welcome to his opinion). it is far more important when you're starting out just to go with what you know and just produce something! nothing is more motivating than when your code starts working and first starts becoming playable.

don't listen to idiots, especially ones that think one language is going to get you hired. game development demands that you learn more and more to satisfy it, and you'll find yourself, if you stick with it, learning many new things far more valuable for job prospects than syntax structure.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
oops, that STL thread was here
http://www.gamedev.net/community/forums/viewreply.asp?ID=2315762

and what are System.out calls doing in benchmark tests?? but guess what, hes fine, cause he included this disclaimer (note: not to be taken seriously by language fanboys)

Quote:
Please note that all the disclaimers, warnings, and notes by Doug apply to this shootout as well. This is ncluding, but not limited to:

* ...some solutions as currently presented are unoptimized...
* ...please take the current results with a grain of salt...
* ...you might even find that I have horrible bugs in my testing method...
* I'm doing it so that I can learn about new languages, compare them in various (possibly meaningless) ways, and most importantly, have some fun.

And, above all:

* "There are lies, damn lies, and benchmarks".

and notes with every language that the benchmarks could be improved.

heres a hint: if your language performs that poorly in the "hello world" test (48th), maybe you shouldnt include a print string call in the other benchmarks!

Share this post


Link to post
Share on other sites
TheOther    150
A finished game in C++/C#/Java/VB/.NET/Python/Perl/Ruby/Torque/Blitz/OpenGL/Direct3D/Assembly/Win32/MFC /logo/Allegro/SDL/BASIC/Dos/XBox/PS2

beats any unfinished
C++/C#/Java/VB/.NET/Python/Perl/Ruby/Torque/Blitz/OpenGL/Direct3D/Assembly/Win32/MFC /logo/Allegro/SDL/BASIC/Dos/XBox/PS2

game.

Don't worry so much about what's "right" or "wrong" for games. Just finish 'em and the rest will fall into place.

Share this post


Link to post
Share on other sites
chollida1    532
If you know Java and don't know any other languages then I'd say why not, try game programming in Java. Its been my experience that its the math and algorithms that trip me up more than the language.

Though Its also been my experience that most of the game related tutorials I find are written with C/C++ in mind so knowing C/C++ may be something you'll have to tackle eventually.

I don't know if Java is slower than C++( I've never seen any good come out of debating that:)), but if I'm hiring I'd take the guy who has programmed a game rather than the guy who is good at C++ but hasn't produced anything game related.

Summary: IMHO Languages are easier to learn than game development in my opinion:) Start learning Game development fist, languages second:)

Cheers
Chris

Share this post


Link to post
Share on other sites
dtaylorjr    180
Hi,
Java is a great language for game development. It may not be quite as fast as C++ - but is it really a major issue if Java is 2% - 5% slower than C++? If you know Java better than C++, you should definitely stay with Java. 3D Cards, and cpus are getting faster every day. One of the benefits of developing in a Java (and OpenGL) engine is that your product can run on multiple platforms without too much additional effort. I highly recommend going to www.jmonkeyengine.com to download and learn about an awesome Java 3d scene graph engine. The engine is built around Java, and OpenGL. The engine is fast and very easy to pick up and develop for. NCSoft (the company that produced Guild Wars) recently hired the creators of the Java Monkey Engine to create something that is based on this engine (I'm assuming it is a game). I prefer to develop in Java. It's easy and fast to develop robust object oriented programs, yet it is much more mature (as a language) than something like Blitz Max. C++ is great for an experienced C++ developer, but a Java developer should probably stay with Java.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Does anyone have any good references for a java+openGL solution that can produce stand-alone/native executibles for PC/Mac/Linux?

The biggest problem with Java is that it doesn't seem to be as nicely self-contained as something written in c/c++.

However this is something I'm still looking into, I'd love to be proven wrong ;)

Share this post


Link to post
Share on other sites
JWalsh    498
First, Let me apologise if I gave the impression I wanted to start a Java flame war. That was not my intention. I'm a big fan of Java and use it often for Servlet applications. My goal was simply to answer the questions asked by the OP. Here's a refresher:
Quote:

Initially I'd planned on learning how to do things with Java (since I have some background in Java), but I'm not entirely convinced Java is the best choice for this.

Now my question is, how does java compare to languages like C# and C++ with regards to game development and how widely is it used?


With that being said...here's the facts, and the OP can decide which language is right for him.

JUST THE FACTS:

  • C++ is the standard programming language of all major platforms - PC, Macintosh( technically 'Objective C'), PS2, XBox, XBox360, and likely PS3.

  • There are more game development sites which cater to C++ game development than Java development. This doesnt mean better, just more.

  • There are more lines of code written for games in C++ then Java - giving a wider pool from which to draw libraries and examples.

  • C++ and C# both have bindings for both DirectX and OpenGL, giving you more choices for hardware acceleration. Java only supports OpenGL to my knowledge, though someone said Java3D might have DirectX bindings - need to research that a bit more.

  • C# IS being used by industry professionals in the arena of Tools development and will likely expand into game development itself due to its reflection capabilties.

  • C# is easier to work with than Java for tools development because it uses the same IDE as Visual C++ - important for dev studios which already use C++ for development.

  • C# and Managed C++ are both .NET compatible languages which allow the assemblies to be used with ANY other .NET language, including Visual Basic or each other.

  • The .NET Framework now has native CLR's running on both Linux and Macintosh - allowing portability to other platforms.

  • After searching through Gamasutra's job posting I found that all but 2 positions specifically stated they wanted C++ programmers. The 2 positions that wanted Java also wanted C++ and were advertising either a Cellular game programming position - or web programming - as I indicated in my first post.

  • On Gamasutra's job postings the following companies are currently advertising that they are looking for programmers with C# programming experience. I stopped looking about half way down, but I know there were a few more.
    Heavy Iron Studios
    Blizzard Entertainment

      With ALL of this being said, Java is still a perfectly valid language for developing games, especially games for webpages or cellular devices...however, ASP.NET (C#) also allows development of web-based games.

      In the end, pick which language you are most comfortable with. But keep in mind, if you ever want to be considered seriously for a professional game programming position, you'll need to have mastered C++. As it seems you're just starting with Java programming as well, you might as well make the switch to C# or C++ now. If you're attached to Java and want to continue using it, more power to you. Its a fine language.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by Anonymous Poster
Does anyone have any good references for a java+openGL solution that can produce stand-alone/native executibles for PC/Mac/Linux?

The biggest problem with Java is that it doesn't seem to be as nicely self-contained as something written in c/c++.

However this is something I'm still looking into, I'd love to be proven wrong ;)


i personally use lwjgl...great library. it just so happens i was just poking around aldacron's blog and saw this:

http://www.cokeandcode.com/node/422

a blog entry about using GCC/GCJ 4.0 (via mingw i believe) to compile it into a windows executable.

*that said* personally i like the launch4j option...open source tool to wrap your jar up into an executable along with a jvm if you want it. the dynamic libs have to be in a separate folder, but thats par for the course for any release game.

this tends to be a good idea, btw. one of cas's posts recently on the lwjgl or java gaming forums was about he was getting much more purchases from downloadable exe demos than webstart ones.

Share this post


Link to post
Share on other sites
Promit    13246
Try to use PhysFS in Java. Go on, try.

Done writing your JNI wrapper DLL yet? What's that? The JNI homepage's tutorial link is broken? Happy googling.

Now, try to use PhysFS in C#. Assuming you didn't find the Tao.PhysFS wrapper (which is a single CS file you include into your project), you'll find that you can write your file loading code (in my case, a threaded asynchronous loader) right in C++/CLI and export to C# no problem.

Now try to get PhysX (Novodex) into Java. Looks like you have to rewrite every single class in JNI...if JNI can even handle classes. Alternatively, you need to pull some kind of voodoo to implement a java interface for a scene graph node in C++. Enjoy yourself.

In C#? Just write your physics scene graph node in C++/CLI, and use it from C# as if the entire thing was managed.


This story repeats pretty much verbatim for most libraries on the market.

Share this post


Link to post
Share on other sites
smitty1276    560
Quote:
Original post by Promit
This story repeats pretty much verbatim for most libraries on the market.


Boy... you would almost think that writing games in Java is some kind of nightmare after reading that. It isn't.

Also, isn't the PhysX stuff like a $50,000 license? I don't think that's applicable for this conversation. It looks like you took the most ridiculous example you could think of and tried to pass it off as an everyday run-of-the-mill Java development problem.


Share this post


Link to post
Share on other sites
smitty1276    560
Quote:
Original post by jwalsh
smitty1276: Where do you get that it is 3 years old?

According to the website the benchmarks were done with:

Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
Microsoft (R) Visual C# .NET Compiler version 7.00.9466

Unless I'm mistaken those are both 1-2 years old...


Well, Java 1.4.2 was out in 2003, and the versions of everything else were at least 3 years old (cygwin from Feb '03, Windows 2000, etc). My whole point was simply that it is a crappy benchmark, and that's assuming you can even make heads or tails of the results. If you are going to judge based on those numbers, we should all be using ada.

I'm not commenting on the validity of your assertion. C++ is certainly faster, but there is no reason why C# would be faster than JIT Java. The difference is absolutely negligible for the vast majority of hobbyist game developers.



Share this post


Link to post
Share on other sites
Mike2343    1202
I do believe their Physics engine is now free if you include support for their hardware:
http://physx.ageia.com/developers.html

Share this post


Link to post
Share on other sites
Promit    13246
Quote:
Original post by Mike2343
I do believe their Physics engine is now free if you include support for their hardware:
http://physx.ageia.com/developers.html
The conditions are free for non-commercial and free for commercial as long as you support the PPU (which most of the time they also give to you.) I also gave the example of PhysFS, which is free. Still, the situation is bad for APIs and worse for C++ ones, and the sheer frustration of JNI is mind boggling.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
I would just like to state I currently in the industry as a Java programmer and there are many frustrating days I just wished Java was not invented. It would make things so much easier if I were programming in C++ or C# instead of doing some of these "reduculous" hacks to get things working in Java.

Java sucks!!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
AP: learn to spell "ridiculous." also, obvioulsy, how to program in java.

Promit: JNI is not that difficult. first of all, within 5 seconds of searching for the jni tutorial on java.sun.com i got

http://java.sun.com/j2se/1.4.2/docs/guide/jni/
http://java.sun.com/docs/books/jni/
http://java.sun.com/docs/books/tutorial/information/download.html
http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/jniTOC.html

second, there are a lot of great automated tools out there that will just read header files and spit out the requisite JNI resources. the one that lwjgl uses, i believe, is gluegen; JOGL just switched to it as well.

while youre right that theres more trouble when dealing with C++, its still not that bad. in the case of physx you would probably take the same approach, writing a c++ scene graph with a jni interface. no "voodoo" required.

a paper like this one
http://www.cs.technion.ac.il/~gabr/papers/cuj_jni.pdf
is a good introduction. just search for something like "jni c++". a little googling work goes a long way!

Share this post


Link to post
Share on other sites
killingdjef    122
Interesting replies!
Thanks!

Basically I can conclude that when you start with indie game development you already have alot on your mind designing the game. Learning a complete new language with it would make it harder.

Still, some people say that AAA-games are unachievable when making a game in Java and that you should use C++. I am curious what makes a AAA-game then. If you see a AAA-game as a game which had a dedicated team of 60 employees working on it for 4 years then I agree that it is not achievable. Having such a large development team would naturally mean you'd use the best of the best.

But given that a smaller team of hobbyists work on a game engine and create a game, would it be possible for them to make a living out of it? There is a difference between selling millions of copies world wide of selling one thousand.. or maybe 10 thousand but with lower development costs I don't see why it is necicarilly wrong (I get this impression) if you want to make a game but can't fit the "AAA-quality game"-standard.

Share this post


Link to post
Share on other sites
Aldacron    4544
Quote:
Original post by killingdjef
Still, some people say that AAA-games are unachievable when making a game in Java and that you should use C++. I am curious what makes a AAA-game then. If you see a AAA-game as a game which had a dedicated team of 60 employees working on it for 4 years then I agree that it is not achievable. Having such a large development team would naturally mean you'd use the best of the best.


This is the biggest misconception there is. There is no inherent problem in Java that prevents a AAA game company from using it to make games. I've already linked above to a blog by a Java developer who was hired by NCSoft recently to start work on an unannounced project. It may never see the light of day, but they are exploring it. There have been a handful of AAA games that used Java in one capacity or another. Even the Star Wars Galaxies servers use Java.

The reasons you don't see more of Java in the AAA space are: the lack of JVM availability on consoles, a lack of third party Java tools (most companies license game engines and rendering components these days to save dev time), and to some extent the myth that Java is slow continues to persist. For most established shops it's just not a good investment.

Sun is working to solve some of the problem. Project DarkStar (aka the Sun Game Server) is a MMOG server technology Sun is developing to get more big shops using Java on the server side. It supports both Java and C++ clients to help make it more attractive. They've already are in talks with some companies, though it's going to be a while yet before we hear who they are.

Promit also makes a good point above about language bindings. There's a lot of stuff you might want to use for which bindings don't exist. Several open source projects have sprung up to give direct, cross-platform access to OpenGL, OpenAL, native input, DevIL, FMOD, and so on. There are loaders for all sorts of file formats, including ogg/vorbis. Someone even started a binding to the ODE physics library, but now someone is also porting ODE to Java. There's a lot of stuff out there that people are creating to help make games with Java, but many tools you might want to use aren't available yet. You would have to create your own bindings to use them. Though, JNI isn't near the beast he makes it out to be.

It took the game industry a very long time to adopt C++. This article at Gamasutra, from 1999, has an interesting passage in it. These days, C++ is all the rage in the games industry and most people will raise their eyebrows if you suggest using C, or if you reject std::string or other STL constructs, or, more and more, any of the Boost libraries. But just 7 years ago, the author of that article felt the need to defend his choice of C++ for his math data structures. This line is most telling:

Quote:
It is a common misconception that C++ produces slow, bulky code and is therefore unsuitable for game programming.


There, a C++ programmer defending the performance of C++ against the misconception C programmers propagated. Sound familiar?

Seven years from now people will most likely be arguing about the performance of some other language. I have no idea whether Java or C# will gain any ground in the game industry in the next few years. But there will be companies starting from scratch who choose new technologies. They will develop game engines in languages other than C++. Alternatives will become available. Emergent isn't going to suddenly rewrite Gamebryo in Java or any other language, but you will see companies with competing technologies that aren't in C++. The industry gradually evolved from assembly, to C, to C++. It will evolve again, though C++ isn't going to disappear (even assembly hung on for a long while, as RollerCoaster Tycoon demonstrates).

Quote:
But given that a smaller team of hobbyists work on a game engine and create a game, would it be possible for them to make a living out of it? There is a difference between selling millions of copies world wide of selling one thousand.. or maybe 10 thousand but with lower development costs I don't see why it is necicarilly wrong (I get this impression) if you want to make a game but can't fit the "AAA-quality game"-standard.


It's very possible to make a living at developing games even as a solo developer. Look at these indie sales stats at GameProducer.net. Some of those games come from small teams, some come from solo developers. Cliff Harris at Positech Games, whose game Democracy (a C++ game) has stats in the list, left LionHead Studios last year to go full time indie. oddlabs, whose game Tribal Trouble (a Java game) also has stats available there, developed TT while they were in college. They are now working on game dev full time just from the TT profits.

When deciding which technologies to use, one thing to keep in mind is your ultimate goal. Aiming to get into the AAA industry with a big studio is a world apart from aiming to develop your own downloadable games. In the former case, the skillset you need is very specific - C++, Python, Lua, perhaps a specialzation in one of the fields of graphics, AI, networking, UI, tools development, and so on. In the latter case, the skillset you need is determined entirely by you, your target platforms, and your target market.

Arguments that the AAA industry doesn't use Java or C# just have no meaning in the context of the downloadable games industry. In that space, people use everything from C++, to Java, to BlitzBasic, to Shockwave, and everything in between. All of the companies in those links have had some level of success in the downloadable games space, regardless of the language they used.

People on these forums tend to give advice from a AAA perspective (particularly those who aren't actually developing any games, AAA or otherwise). So always keep your goals in mind when getting advice and take all advice you get in large communities like this (even mine) with a grain of salt.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this