Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Ever since I was a little kid, my dream has been to develop games. Well, now that I am older, more mature, and have some programming experience, I would like to start. However, I would like to turn this into a career. The problem, is that my language of choice is Java.

Now, I am not intending this to be a Java vs. C++ question, but rather, is Java an acceptable language for serious game development, instead of lower level languages like C++. By serious, I mean high quality graphics, and being able to play a game with said high quality graphics, without much lag on decent computers. Also, eventually, possible making it to consoles. I have scoured the internet, but there are not very many resources for Java game development, not nearly as many as C++. In fact, most engines are written in C++. Once, I tried to play a made with jMonkeyEngine. The game was terribly slow, to the point where my computer froze. I had no other Java applications running and nothing too resource intensive. Keep in mind, that my computer can play most modern 3D games with ease.

So, I am really serious about game development, is Java still a viable choice? I have tried multiple times to learn C++, but I don't really like the language. I don't really know why, but usually, whenever I try to learn, I can never grasp the topics. Also, my most of my friends know Java, and one is even anti-C++, saying that no one knows how to use it right. Then, he goes to say that "there is no right way to use C++, that it can not be used correctly. The nature of the language prevents good code." Also, if I continue to learn and improve Java now, and it turns out that later I am required to learn C++, will making the switch be difficult?

So, in short, can Java be taken serious, for serious game development. This includes heavy graphics, fast game play without lag, and possibly, and easy switch to consoles?

share|improve this question
22  
Isn't minecraft built with java? Or mainly OpenGL? Oh and check out C# if you are not 100% set on java, as it is awesome. –  Aralox Mar 14 '12 at 0:40
7  
Why don't you come to the Stack Overflow C++ Chat? We love C++, we think it can absolutely be used right, and we know how to do that, and we'd be totally happy to share. –  DeadMG Mar 14 '12 at 0:59
9  
Minecraft is java + LWJGL + Notch's coding skills, so performance-wise it is TERRIBLE. –  Ef Es Mar 14 '12 at 1:25
4  
You're going to get a lot of misinformation because the Java/C++ wars burn brightly, be prepared to ask for specific examples before accepting an opinion and also to research more on your own =) That being said, I agree with @loganfsmyth that you will need to know many languages because only then can you choose the right tool for the any task. In the immediate future if you just want to learn "game style programming" then use what you're comfortable with (Java) and then learn C++ later. Heck, later you may be doing content pipelines in C# and games in Java ME, hard to predict =) –  Patrick Hughes Mar 14 '12 at 2:08
6  
Obligatory "Have you considered using Unity?" post. Since everyone else is suggesting languages and tools. –  thedaian Mar 14 '12 at 18:18

8 Answers 8

up vote 42 down vote accepted

Yes it is, check this list for a proof. Those are some games made with Java using The Lightweight Java Game Library (LWJGL). It is a low-level framework, which provides OpenGL for high quality graphics and OpenAL for sounds. It also provides input API. With these you can quite easily get started to serious game development in Java.

I am currently writing my second 3D game as a hobby project in Java, and I just love it. In the past I used to write my games with C++, but after switching to Java there is no going back. Supporting multiple operating systems with Java can be very easy, for example my previous Java game, which I developed in Windows for a year, worked in Linux right away and in OS X with only one bug without any need to compile anything on those platforms.

On the other hand, with Java you have couple of problems.

  1. Garbage collector. As others have stated, non-deterministic memory management is a problem, and you need to code that in mind.
  2. Lack of 3rd party libraries. Most of the available libraries do not support Java. On the other hand you always have the option to call these native libraries from Java also, but it's more work to do so. There are also Java ports or ready-made wrappers available for popular libraries, for example I'm using JBullet - Java port of Bullet Physics Library. On the other hand Java has a huge class library built-in, which reduces the need for third party libraries that are not game related. The lack of libraries has not been a problem for me, but I can imagine that it can be for others.
  3. Java is not supported by popular game consoles and there is no easy switch to those from Java as far as I know. On the other hand Android, which is a popular mobile platform, uses some form of Java. This is an option also, but don't except the same Java code to work both on a PC and Android device.
  4. Smaller community. Most game programmers use C++ and in my experience often dislike Java. Don't expect to get as much help from others. Don't expect to get a job in game development without C++ skills.
share|improve this answer
1  
Minecraft uses LWJGL - why would they not have that listed? :| –  BlueRaja - Danny Pflughoeft Mar 14 '12 at 14:24
9  
@BlueRaja: Because Minecraft's performance is abysmal :) -- With regard to the GC, some of the better Android game development tutorials explain methods for making the "dreaded GC cycle" less of a problem for gameplay. Example –  Justin ᚅᚔᚈᚄᚒᚔ Mar 14 '12 at 16:19
3  
Of note is that many of the techniques used to mellow Java's GC cycle and gain performance are also important for C++ engines. If you write expensive code it doesn't matter what language you're writing in. –  Patrick Hughes Mar 15 '12 at 0:03

Not really. Here's the thing- firstly, there's very little in terms of existing libraries for Java compared to the virtually everything that is for C++.

Secondly, Java as a language simply doesn't lend itself well to game development- I mean, for example, if you're dealing with GPU buffers then Java does not provide a language feature which will aid you in ensuring they are correctly locked and unlocked or disposed of, which C++ does. Plus, there's the performance problem- and the GC is non-deterministic, which is super-bad for a game.

I have never observed any non-indie game which spent significant time in a language that was not compiled to native code prior to execution, and even the indie games which do so are a rarity. So my belief right now is that it simply cannot be done.

Also, if I continue to learn and improve Java now, and it turns out that later I am required to learn C++, will making the switch be difficult?

Yes, absolutely it will. Java and C++ are vastly different, despite their superficial syntactic similarities. Java experience counts for virtually nothing when learning C++.

Gameplay over graphics is a viable choice, and you can see it in the success of games like Terarria and Minecraft. But if you intend on creating srs graphics, then it's not going to be doable in Java.

share|improve this answer
4  
+1 since he specified heavy graphics, fast game play without lag. –  Joshua Drake Mar 14 '12 at 15:50
    
Java's lack of unsigned data types also stands against it. Yes, you can work around it, but it's not ideal and you'll be using code that doesn't really reflect the underlying data correctly. –  Darth Satan Mar 30 '12 at 20:25
    
@deadmg Is case of locked and unlocked, are you referring to some DirectX api functionality? & Can you tell me, what's so bad about having non-deterministic GC. –  iamcreasy May 3 '12 at 23:00
    
Non-deterministic GC can equate to dropping frames, if you get a bad stop the world pause and it locks things up for longer than it takes to render the frame. In practice this doesn't really happen often/ever if you plan your memory use, JVM's collectors can be configured for low pause (well within safe limits for frame dropping). Still, it's not a fun thing to have to deal with. You end up having to hand back significant amounts of the productivity that you gained when you left C++. –  Michael Oct 22 '12 at 2:27
    
+1, except the bit where you say Java experience counts for nothing. Take a proficient Java programmer, give them a C++ compiler and a copy of SDL or SFML, and they'll be able to make something interactive in a day or two. It won't result in particularly good C++ code, but it's a start. –  Rick Yorgason Jun 5 '13 at 15:13

So, I am really serious about game development, is Java still a viable choice? I have tried multiple times to learn C++, but I don't really like the language. I don't really know why, but usually, whenever I try to learn, I can never grasp the topics.

If your reason for choosing Java is that you couldn't understand C++, your Java programs aren't going to be fast enough for high quality graphics. Using a higher level language should be because it makes you more productive, not because you couldn't understannd the lower level language.

I don't think it's an entirely bad idea to write a game in Java, especially if the game is simple, but you're immediately going to run into performance issues in Java if you're using it as a crutch.

So, in short, can Java be taken serious, for serious game development. This includes heavy graphics, fast game play without lag, and possibly, and easy switch to consoles?

  1. Heavy Graphics: Possible, but you're going to be doing the same thing in Java/LWJGL as you are in C++/GL: writing bytes to GPU buffers and/or using the deprecated display lists like Minecraft does. If you don't understand the memory management, you're not going to do this correctly either.

  2. Fast game play without lag: Not an easy task in any language, and you're more likely to shoot yourself in the foot either way without putting thought into it.

  3. No, Java is not going to be available on consoles.

share|improve this answer
    
As a side question, what replaced the display lists when they were deprecated? –  Suds Mar 14 '12 at 2:59
    
@Suds: Programmable pipeline, I believe. –  DeadMG Mar 14 '12 at 3:01
    
ha! already covered it. VBOs: gamedev.stackexchange.com/questions/22170/… –  Jimmy Mar 14 '12 at 3:01
    
Mobile platforms could be considered consoles. I realize he was probably talking about the big three, but Android uses Java and plenty of games are created for it. –  Amplify91 Mar 14 '12 at 3:27
1  
@Amplify91 yes a few games are written in java for android. But most good games and probably all graphic intensive or multi platform games are written in C++ using the Android NDK. –  Coyote Mar 15 '12 at 16:15

An experienced programmer will generally know many programming languages - learning extra programming languages isn't too hard once you know one well. However I would strongly recommend that C++ shouldn't be your first language, and probably not the second one either.

That's because C++ gets a lot of its efficiency from not doing any significant runtime error checking. For example accessing an element off the end of an array in Java will always throw an exception telling the programmer exactly what's wrong. In C++ you may get lucky and it will crash immediately, but very frequently it will silently trash some other data and the error won't show up till much later on.

I'd suggest you stick with Java for now (or switch to C# if you prefer that). That will let you get things done quicker than using C++, and performance on a PC shouldn't be an issue.

Think about learning C++ after you've completed a few projects in safer languages. C++ is what you'll need for most professional game development jobs.

Note that with the exception of C#/XNA getting a game you wrote onto a console at a minimum requires you to set up a company, with an office, and have a large budget available for development hardware and other expenses.

share|improve this answer
    
This is also exceptionally true because other languages beyond C++ will give you a sense of accomplishment. C++ can take hundreds of hours for what can feel like nothing. Learning other languages first lets you get your feet wet. –  Darkenor Apr 22 '13 at 17:07

Disclaimer: This doesn't exactly answer your question. However, I have attempted to (briefly) mention some points that may be of interest to you.

The reason that you see so much about C++ is because C++ is still the industry standard -- the most common language for consoles, etc.

Java is not frequently used. Minecraft is a pretty popular game that made it big with Java; but it's not that great graphically. Spiral Knights is not bad -- also made in Java, with significant graphics.

If you like Java, C# is very similar in syntax, with the advantage that it can interop with C++ -- so low-level stuff can be done in C++ if necessary. Unity can use C# for scripting, and XNA is an excellent choice.

Again, Java is not widely used. If you like the style and syntax, I think you'll find C# to be a very similar, very pleasant coding experience.

I hope your dreams make it, it's a lot of fun along the way :)

share|improve this answer
7  
Lots and lots of inaccuracies in this posts. Minecraft "bad" graphics are not (heavily) related to the language. MC bad performance is directly related to Java being a bad language for games because HUGE performance issues, and LWJGL being an unsuitable library for big coding projects for the same reason. But the biggest factor was Notch's bad coding and implementation, which is being fixed...slowly. C# gives you all the ups of managed memory without most of the Java performance problems. The downside is that C# is heavily Microsoft-centered for both games and applications. –  Ef Es Mar 14 '12 at 1:18
2  
@EfEs: I hate to break it to you, but managed memory is terrible for games, and people who code games in XNA have to spend more time managing memory than people who code in C++. The non-deterministic nature of the GC means you have to pool practically everything and avoid allocation like the plague- not the way the language was supposed to be used. –  DeadMG Mar 14 '12 at 1:42
    
This answer was not meant to be 100% accurate; I only cited examples I know vaguely about. Feel free to DV. –  ashes999 Mar 14 '12 at 3:13
1  
@DeadMG I know C++ is the way to go, I was just trying to explain that C# is better than Java for games. –  Ef Es Mar 14 '12 at 10:19
4  
Being a long time C# developer (not game developer thought) I believe that pooling and memory management are great issues for any badly designed system. People with the C/C++ mindset and ways of development I know, hardly gasp into the managed memory, design and architecture patterns that must be used and take advantage of them in a language like Java/C#. What I am trying to say, is not that C/C++ techniques or products is bad, but that even if you use simpler languages in terms of syntax (like Java and C#), you still need lots of experience to design your game the right way. –  Ivaylo Slavov Mar 15 '12 at 11:34

This doesn't answer your question; the graphics and console issues seem to be something you very much need to consider. Also GC affects on performance. But what I write about:

If you are writing large, complex, OO programs, you will write them 5 times faster in Java than C++. Also, maintenance will be vastly easier. I switched, (admittedly for non-game software), and my productivity skyrocketted. C#, another good alternative, is harder to learn than Java because there's a lot more of it. When you know it, you can write code even faster than in Java; it offers you a lot of tricks. However, I find those tricks can make maintenance difficult. And then there's Java doc, which helps with the Sun libraries and your own old code. C# has nothing quite like it.

I did a big hairy game in Java and found the language perfect, but my graphics were elementary and it wasn't a shooter where a tenth of a second was an eternity to the players. Also, I expect to add a lot on to it later, whereas I think most people just go and write a brand new game.

share|improve this answer

Look dude, the simple answer to "Is Java viable for game dev" is an obvious yes. You can use any programming language to make games. That doesn't mean you should.

Probably the very things that turns you off from C++ (low level memory management, no garbage collector, having to pay attention to pointers, structs as arrays etc) are the very things that you should learn if you want to exploit a computer's resources most efficiently. Your games will run best if you are exploiting the computer's resources most efficiently.

Java does some things (such as array bounds checking) that just make it run slower. In this optimized Java Perlin noise example code, the author commented "(array access is a lot slower than member access)". This kind of thing is pretty counter intuitive coming from a C++ background. But in Java, such things are.

I say stop dodging the bullet, learn C++, and use it.

share|improve this answer

You should do it in the language you know best until you can afford a formal education (Bachelor's of Science?) in Computer Science, emphasizing game design. You could possibly use your game to get a scholarship, especially if you can say "I did this without any formal training in Java"

Modern JVMs, even the one from Oracle, have many, many features to address the concerns people have brought up here. You can use different garbage collectors to get more deterministic garbage collector behavior. I don't have extensive experience with the 3D libraries - only a little with Java3D - but nobody here seems to have complained about them. Escape analysis now allows lock elision and much faster/negligible allocation of very short-lived objects.

The problem is, whether you choose Java of C++, you'll have to learn how to properly use concurrency and have a good understanding of memory management. After all, you can just as easily screw up with malloc as you can with new. I don't know what the tools are like for C++, but the profiling tools for Java are fairly easy to use, free, and integrated with the IDE. You can use them to track down performance problems and learn.

share|improve this answer
4  
Formal education in CS is worth jack shit for actual programming skills in any discipline. I would know, I'm in my third year. –  DeadMG Mar 15 '12 at 0:00
4  
Definitely disagree with DeadMG. Having graduated and picked courses I like, CS took my game development powers from 10% to 100%. It didn't teach me UI, iconography, etc. but actual, real coding. –  ashes999 Mar 15 '12 at 12:00
2  
@ashes999: Then you got lucky. My course is worthless and I know that there are many others who feel the same. –  DeadMG Mar 19 '12 at 14:49
2  
@DeadMG it's hard to see when you're studying. Once you work a couple of years F/T, and learn other complimentary skills, you'll see. I did. But maybe I just paid a lot of attention and tried to apply everything to my game dev hobby. –  ashes999 Mar 19 '12 at 18:17
1  
I'd say that it depends on the school and the professor. I had a few great programming classes where I learned a ton; and I had a few where I actually felt I lost knowledge by attending. It's all on having a good professor or not. IMO. –  Nate Mar 30 '12 at 14:48

protected by Byte56 Jun 5 '13 at 14:44

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.