Java - any good for game programming?

Java - any good for game programming?

Postby KroArtem » 14 Mar 2011, 18:17

Split from the Scourge2 showcase thread - Scourge2 is written in Java

Java makes me feel sad :'(
KroArtem
 
Posts: 375
Joined: 26 Aug 2010, 19:04

Re: Scourge2

Postby charlie » 15 Mar 2011, 22:18

KroArtem {l Wrote}:Java makes me feel sad :'(

Why? Ignorance is bliss. ;)

Some good games made in Java include Revenge of the Titans, Wakfu, Spiral Knights and Starfarer.
Free Gamer - it's the dogz
Vexi - web UI platform
User avatar
charlie
Global Moderator
 
Posts: 2131
Joined: 02 Dec 2009, 11:56
Location: Manchester, UK

Re: Scourge2

Postby KroArtem » 15 Mar 2011, 23:31

charlie {l Wrote}:
KroArtem {l Wrote}:Java makes me feel sad :'(

Why? Ignorance is bliss. ;)

Err, I can't understand your idea, even with translator :(
I think Java is not a good choice for creating games. Of course, I can be wrong, because I'm not a programmer, but as like 'Mono makes baby Gnu cry', Java makes me feel sad (don't know why).
However there are some really good things written in Java (for example, Jdownloader or sweet home 3d) and when I'll have enough space on my hard drive, I'll definitely try to install Scourge 2 ;)
Now feel free to criticize me :D
KroArtem
 
Posts: 375
Joined: 26 Aug 2010, 19:04

Re: Scourge2

Postby charlie » 16 Mar 2011, 13:54

Look at www.jmonkeyengine.com or www.ardor3d.com before you say Java is no good for games.

Java is not slow and has not been for a decade, ever since the arrival of JIT. Java is a more productive language than C++ (better tools, better structure, fewer nightmarish problems). It is a good tool to use for games if you are good with Java.

C++ is good if you know it well. So is C#. And D. Of them all, I would point a learning programmer at Java. That's my opinion.
Free Gamer - it's the dogz
Vexi - web UI platform
User avatar
charlie
Global Moderator
 
Posts: 2131
Joined: 02 Dec 2009, 11:56
Location: Manchester, UK

Re: Java - any good for game programming?

Postby Edward_Lii » 16 Mar 2011, 14:55

Hello KroArtem,

KroArtem {l Wrote}:
charlie {l Wrote}:
KroArtem {l Wrote}:Java makes me feel sad :'(

Why? Ignorance is bliss. ;)

Err, I can't understand your idea, even with translator :(
I think Java is not a good choice for creating games. Of course, I can be wrong, because I'm not a programmer, but as like 'Mono makes baby Gnu cry', Java makes me feel sad (don't know why).
However there are some really good things written in Java (for example, Jdownloader or sweet home 3d) and when I'll have enough space on my hard drive, I'll definitely try to install Scourge 2 ;)
Now feel free to criticize me :D

I'm a Java programmer myself and somehow most people think Java isn't suitable for game development.
In my opinion that's a very big misunderstanding, and as you said there are some great programs written in Java.

There's even a forum for java game development: http://www.java-gaming.org/
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Java - any good for game programming?

Postby richardjames13 » 17 Mar 2011, 04:59

Games can be written in almost any programming language. The quality of the game is dependant upon the skills and efforts of the person making it not the language they choose.

I've written games in C, C++, Python, BASIC and Assembler. The quality of my work was more dependant upon my effort at the time than the programming language I chose.

Of course some languages are actually slower, such as BASIC and Python but a good game developer takes this into account and does not let it show through.

Developers make games possible not programming languages.
richardjames13
 
Posts: 27
Joined: 03 Jan 2011, 05:16

Re: Java - any good for game programming?

Postby oberhamsi » 17 Mar 2011, 12:59

Is there a type of game java is particularly suited for?

The thing I love about java: a lot of great, stable (!), well documented libraries.
User avatar
oberhamsi
 
Posts: 105
Joined: 06 Sep 2010, 18:38
Location: EU

Re: Java - any good for game programming?

Postby Sauer2 » 17 Mar 2011, 17:40

Once you know how to keep the garbage collector from working, it's possible to make High-End games, since JVM normally is nearly as fast as C, nowadays.
Also see: http://jmonkeyengine.com/

PS: The problem is common with all programming languages that have advanced automatic garbage collection. Even Lua, that's why Squirrel exists. I also recommend to take a look at Pike, if you have problems with garbage collection, since you can disable automatic GC and clear up everything manually.

EDIT:
The only problem I see with Java is, that is not secure how open it will be in the future. If Oracle really want to make proprietary, screw open source licenses. :(
EDIT2:
Sorry oberhamsi, it seems I understood your question a wrong way. Guess that will be board and card games, since Java doesn't support Hardware accelerated things out of the box AFAIR. ;)
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Java - any good for game programming?

Postby ginkgo » 17 Mar 2011, 18:42

Java is excellent for writing networked code and has a lot of cool introspection and reflection features, which are useful for code roll-out.

Take a look at Minecraft, probably one of the most popular Java-games at the moment.

Writing this in C++ would have been a lot harder. The automatic update when starting the app would probably be impossible. Especially when it has to be cross-platform.

Using Java also allowed Notch to put an early version of the game in a web-applet on the Minecraft homepage. This is probably one of the major reasons why the game has become so successful in the first place. Java is the only language in it's performance class, besides maybe Flash, which can do this.
ginkgo
 
Posts: 15
Joined: 14 Dec 2009, 17:10

Re: Java - any good for game programming?

Postby charlie » 17 Mar 2011, 22:00

Sauer2 {l Wrote}:Once you know how to keep the garbage collector from working, it's possible to make High-End games, since JVM normally is nearly as fast as C, nowadays.

I think you're even mischaracterizing the GC issue here. It's just not a big overhead if object management is done well.

Games like Grappling Hook would not be possible if Java was so bad for making games.

http://ghook.speedrungames.com/
Free Gamer - it's the dogz
Vexi - web UI platform
User avatar
charlie
Global Moderator
 
Posts: 2131
Joined: 02 Dec 2009, 11:56
Location: Manchester, UK

Re: Java - any good for game programming?

Postby Sauer2 » 17 Mar 2011, 23:26

Probably. Last time I heard about 200 ms glitches was about Dalvik on Android < 2.0 and that's a total different performance class, I believe. :)
On the other side, that game you mentioned has very high requirements (2Ghz!) for the openarena like graphics i can tell from the video, so maybe it's still an issue for low spec pc alias Via Eden.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: Java - any good for game programming?

Postby richardjames13 » 17 Mar 2011, 23:32

Sauer2 {l Wrote}:Sorry oberhamsi, it seems I understood your question a wrong way. Guess that will be board and card games, since Java doesn't support Hardware accelerated things out of the box AFAIR. ;)


You can use external libraries but these are not guaranteed to have as good documentation as the main Java libraries.

Minecraft I believe uses JNI/LWJGL

LWJGL Lightweight Java Game Library http://www.lwjgl.org/

Description of the gaming technologies in Java http://java.sun.com/developer/technicalArticles/games/gdc2004.html
richardjames13
 
Posts: 27
Joined: 03 Jan 2011, 05:16

Re: Java - any good for game programming?

Postby hc » 18 Mar 2011, 16:15

You can set the garbage collector to concurrent execution and force it to execute often that helps to prevent large random stalls - and there is more work going on at that frontier because there are other realtime applications beside games. There is even a realtime JVM you can buy - but that isn't suitable for games at all at this moment (buy one costly license for one installation). To further reduce issues with garbage collection you may want to conserve object-instances contrary to java desktop-application use (where new objects are happily created all the time) - charlie already mentioned it.

For new programmers and new game projects I would probably recommend to have a look at the GO-language instead of C/C++.

Other than performance issues I think it is important to have a clean language. Java is very clean, has less porting issues, has a lot of libraries, has reflection, has annotations, has garbage collection. Compilation and Compiler issues with C/C++ are another plus for Java and Go. And while raw performance issues tend to become smaller over time (CPU/JIT/VM/GC/Cores/GPU) the legacy code you need to maintain becomes larger. Finally with C/C++ there are about a hundred weird ways for everything with more being added with the next standard. And Go already has some nice devices for Threading. While Java has a lot of neat housekeeping libraries you'll experience that a lot of good libraries are written in C. Therefore with Java (and Go?) you need to rely on wacky 3rd party wrappers or write your own (do you want to write a game or library wrappers?). On the other hand you may use one of those game or 3d-engines (C/C++ and Java) but be aware that for a real game you probably will need to customize components else it stays just a nice tech demo.

If I were to write embedded software and software for real security-critical hard-realtime systems then I would (currently) stay away from Java. At least until the realtime VM becomes open which probably wont happen anytime soon. But for games I don't see an issue with having a probability for a stall because they are (complex!) soft-realtime systems.

That all said, for me it's: Do what you think is best and feel comfortable with - there is a lot to consider.
github.com/hackcraft-de
hackcraft.de
User avatar
hc
LW3D Moderator
 
Posts: 213
Joined: 07 Feb 2011, 10:00
Location: far away

Re: Java - any good for game programming?

Postby oberhamsi » 18 Mar 2011, 20:45

hc {l Wrote}:While Java has a lot of neat housekeeping libraries you'll experience that a lot of good libraries are written in C. Therefore with Java (and Go?) you need to rely on wacky 3rd party wrappers or write your own (do you want to write a game or library wrappers?).


I don't know the C world but I can tell you that there are a lot of high quality Java libraries out there by now - maybe not in all areas needed for game development :) but we are talking open source libraries here, right? then the playing field may level a bit for java and c.

and regarding 3rd party libs: an advantage of java over c/c++ is, that the java language itself is static and everyone uses the same 99% of the language ;)

Java has been around for while by now. There are some excellent libraries around.
User avatar
oberhamsi
 
Posts: 105
Joined: 06 Sep 2010, 18:38
Location: EU

Re: Java - any good for game programming?

Postby hc » 18 Mar 2011, 21:06

Yes, I think that was what I meant with "neat housekeeping libraries", good, pretty, patent, in order, high quality libs for usual business operations. Then again what's not natively available needs wrappers (hardware io, computational complex and older libs). These are things to consider with a problem at hand - not in general. And yes, in java there isn't much choice to what to use, maybe to use templates or not, or to use iterators or not - and the tendency to "new" and "clone" everything (immutable objects) because of GC. And I really do appreciate Java for desktop development but that's another topic.

As for C/C++ I really prefer "old" and tested, portable C libraries for C++ use.
github.com/hackcraft-de
hackcraft.de
User avatar
hc
LW3D Moderator
 
Posts: 213
Joined: 07 Feb 2011, 10:00
Location: far away

Re: Java - any good for game programming?

Postby charlie » 15 Apr 2011, 11:39

Ah, look here:
viewtopic.php?f=3&t=1360

Seems to be a well done, professional game in Java, no? ;)
Free Gamer - it's the dogz
Vexi - web UI platform
User avatar
charlie
Global Moderator
 
Posts: 2131
Joined: 02 Dec 2009, 11:56
Location: Manchester, UK

Re: Java - any good for game programming?

Postby mcc » 17 Apr 2011, 17:59

oberhamsi {l Wrote}:Is there a type of game java is particularly suited for?


Android. Actually your best option on Android, surely.
User avatar
mcc
 
Posts: 4
Joined: 06 Apr 2011, 08:46

Re: Java - any good for game programming?

Postby Tuxide » 17 Apr 2011, 22:41

oberhamsi {l Wrote}:Is there a type of game java is particularly suited for?


Anything that uses WebGL assuming you're using GWT instead of a typical JavaScript optimizer. Java code that builds with GWT should optimize better than JavaScript code because Java is a static-typed language and JavaScript is not. The availability of type information to the optimizer and type-checked code is a bonus.

On the downside, you'll probably be doing a lot of your libraries or wrappers in-house.
Crossfire and Wesnoth played a game of chess. It started out as an open game.
User avatar
Tuxide
 
Posts: 41
Joined: 04 Dec 2009, 04:37

Re: Java - any good for game programming?

Postby MCMic » 22 Apr 2011, 02:11

ginkgo {l Wrote}:Take a look at Minecraft, probably one of the most popular Java-games at the moment.

That's a really bad example : Minecraft is *really* buggy, and really not optimized. Don't take me wrong, I love it, but it's just slow and full of bug, and I'm convinced part of the responsibility goes to java :P
User avatar
MCMic
 
Posts: 723
Joined: 05 Jan 2010, 17:40

Re: Java - any good for game programming?

Postby charlie » 22 Apr 2011, 09:14

MCMic {l Wrote}:
ginkgo {l Wrote}:Take a look at Minecraft, probably one of the most popular Java-games at the moment.

That's a really bad example : Minecraft is *really* buggy, and really not optimized. Don't take me wrong, I love it, but it's just slow and full of bug, and I'm convinced part of the responsibility goes to java :P

No. Just no.
Free Gamer - it's the dogz
Vexi - web UI platform
User avatar
charlie
Global Moderator
 
Posts: 2131
Joined: 02 Dec 2009, 11:56
Location: Manchester, UK

Re: Java - any good for game programming?

Postby richardjames13 » 22 Apr 2011, 09:31

Minecraft was really buggy but it has improved dramatically since the 1.3 release. I don't think the bugginess had to do with Java but was rather a result of the development process.
richardjames13
 
Posts: 27
Joined: 03 Jan 2011, 05:16

Re: Java - any good for game programming?

Postby richardjames13 » 23 Apr 2011, 07:56

And I just found this on the PuppyBlog (Revenge of Titans) http://www.puppygames.net/blog/?p=914
Other than that: I now apologise in advance for the extremely crappy code and terrible inaccurate or nonexistent commenting! It just grew that way. In fact it’s all been growing for 10 years and the subject of constant bodging, retrofitting, and general breaking and poor design. I have it on good authority from Markus that it’s not quite as horrible as the Minecraft code but I suspect it’s not far off.


You can use a good tool to make a shoddy product (Which is why I never do carpentry)
richardjames13
 
Posts: 27
Joined: 03 Jan 2011, 05:16

Re: Java - any good for game programming?

Postby StudioFortress » 21 May 2011, 12:35

I've made a few very small, but complete, Java applets over the years. So I thought I'd signup and share some of my experiences on this.

My general consensus is that yes, Java is an excellent choice for building games. Even with the latest dev versions of Chrome, applets will easily run rings around any other embedded content (Flash, JavaScript or Silverlight). I also found Java + NetBeans is the most productive programming setup I've ever had (and Eclipse is amazing too). That's where most of my praise ends.

The major downside I have is that you have to build A LOT of the cruft yourself. For example embedding an applet that uses LWJGL or JOGL (the old OpenGL bindings) is not trivial (JNLP files for users with Java 6 update 10 and onwards, and the JNLPAppletLauncher for everyone else).

Another example is that if your users have an older version of Java then your applet, then it simply crashes with a stack trace. This makes it look like your applet is broken (I've had people e-mail me saying my game doesn't work, including these stack traces which state they are using an older version). In JavaScript you can test for a feature before using it (and often work around the issue), and Flash will give an error telling the user that their copy of Flash is out of date before offering to update. Java doesn't do any of that. Like with JNLP above, there are ways to solve this (Oracle provides a JS script for making it easy). But again you need to set it all up yourself.

In regards to GC: every game I have written has required multiple object caches (and I've only written small stuff). What is far worse is that some of the core Java collections (namely the HashMap class) are unusable for games. The issue is that they build a new object internally every time a value is added, so if you use them heavily on each frame then the GC will constantly be pausing. Then there are the iterators; every time you use a for-each loop there is a hidden iterator and with nested for-loops on each frame this quickly adds up. Again you can solve all of this by building your own collection classes which have constant memory usage (caching the internal nodes) and that use a callback mechanism for iteration (which is what I did).

In fairness it only takes around 10 minutes to alter a class so that it can be used with a cache, and the custom collections took about a week to fully build. There also also free libraries out there that aim to be high-performance alternatives to the core libraries, but you need to go search them out. The JDK comes with JVisualVM which is one of the best profiling tools I have ever used (and what I use to work all this stuff out). I'd also prefer to have these GC issues then memory leaks and bugs in C++.

I have more issues then that but this all sums up my opinion of Java for games; tonnes of potential, but you need to build a lot before it's really usable!
  • Play My Code - Play, Build, Embed and Share browser games in the browser!
StudioFortress
 
Posts: 23
Joined: 21 May 2011, 11:40

Re: Java - any good for game programming?

Postby Julius » 25 May 2011, 19:00

The recent port of UFO:AI, a quake2 based game, made me remember that there is actually a very high quality port Quake2 to Java (which most likely the UFO port is based on): http://bytonic.de/html/jake2.html

It would be great if someone would take that code and port the Qfusion engine (which runs WarSow for example) to Java (and Android)... that would be an awesome engine to make cross platform FPS games with (good tools, stable, well proven, good graphics... everything).
User avatar
Julius
Community Moderator
 
Posts: 3297
Joined: 06 Dec 2009, 14:02

Re: Java - any good for game programming?

Postby Tuxide » 05 Jun 2011, 07:26

Julius {l Wrote}:The recent port of UFO:AI, a quake2 based game, made me remember that there is actually a very high quality port Quake2 to Java (which most likely the UFO port is based on): http://bytonic.de/html/jake2.html


I know this is about a year old but I couldn't help but post this on this thread after Jake2 being brought up here. It's basically Jake2 (Quake2) modified such that it builds with GWT and runs in an HTML5 browser with zero plugins.

http://www.youtube.com/watch?v=fyfu4OwjUEI
Crossfire and Wesnoth played a game of chess. It started out as an open game.
User avatar
Tuxide
 
Posts: 41
Joined: 04 Dec 2009, 04:37

Who is online

Users browsing this forum: No registered users and 1 guest

cron