4

Presently, i am learning Java from the book The Art and Science of Java and following Standford's Programming Methodology Course.

I would like to do game programming, but only as a hobby.

I was thinking, would Java be a good choice or is C++ the defacto in game programming.

ssube
  • 47,010
  • 7
  • 103
  • 140
Ibn Saeed
  • 3,171
  • 11
  • 50
  • 59
  • Duplicate of http://stackoverflow.com/questions/722908/what-programming-language-is-used-for-video-games , http://stackoverflow.com/questions/49660/is-java-relevant-in-the-game-industry , http://stackoverflow.com/questions/64392/game-programming-in-java , and more – Matthew Flaschen Jun 10 '09 at 09:09
  • Um, what sorts of games? – David Thornley Jun 10 '09 at 20:47

22 Answers22

20

Since you are learning Java i would recommend that you stick to it.

If you are only developing games for fun, it won't really matter what language you use.

Silfverstrom
  • 28,292
  • 6
  • 45
  • 57
  • 9
    Also, C# is a pretty easy sidestep after learning Java, and the XNA framework is highly recomended for hobby game developing – xan Jun 10 '09 at 10:06
  • 1
    Xna allows you to create games for Windows, XBox and Zune. – DMMcKinnon Jun 10 '09 at 13:19
  • 3
    Killer Game Programming in Java is okay, Java 1.6 has seen improvements to the language but nothing that majorly breaks 1.4 apps. However do be careful; that book quickly dives into Java3D examples, and this may not be the path you want to take. Java3D is a scene graph based 3D engine that was too high-level for me, and as an owner of the book I haven't picked it up since making the decision to use JOGL. Definitely +1 to using Java though. It used to have speed issues but nowadays the Hotspot VM runs apps comparable to native apps' speed, and the high-level nature of Java is excellent. – Ricket Jun 10 '09 at 17:01
  • This answer is highly contingent on your definition of "fun" :) – Philip Guin Jun 20 '13 at 16:41
7

That depends, do you want to learn more about C++? Do you need to know? There's still OpenGL libraries in Java that are available, and the concepts would essentially be the same regardless of what language you work in. If it's just for a hobby then I can't see anything wrong with working in Java. In terms of speed however, lower-level languages are prefered.

Kieran Senior
  • 17,960
  • 26
  • 94
  • 138
  • That depends on what you're doing. When pointer arithmetic is required for systems such as real-time rendering then C++ would be fast, and Java simply wouldn't be able to do it of course! In terms of direct comparison though Java is very fast. – Kieran Senior Jun 10 '09 at 11:22
  • 2
    There's not a great deal of difference in it. And particularly if you are using OpenGL heavily - calling it from C++ is not going to make the graphics card go any faster. – Tom Hawtin - tackline Jun 10 '09 at 11:22
  • 4
    Not if you read _real_ reports on speed comparisons. Java is a great language. – Kieran Senior Jun 10 '09 at 14:04
  • Java's speed issues have been fixed for several YEARS. Any articles that complain about Java's speed are probably either outdated or written by someone who only used Java back in its early days, the late 90s, when it was indeed slow. Its speed is very much comparable to that of C++ in many respects. This top Google result shows Java's speed well, but take it with a grain of salt as it is very likely biased: http://www.idiom.com/~zilla/Computer/javaCbenchmark.html It is also worth noting that Java is used at enterprise levels (thus J2EE). If many big corporations trust it, I do. – Ricket Jun 10 '09 at 17:05
  • Everyone I know doing development on videogame systems is still using C++. I'm not sure when that will change. As a hobby, on the PC, I'm sure C# or Java is fine. – Nosredna Jun 10 '09 at 20:39
3

Either would be fine. For a hobby, they both have pretty good low-level support for graphics etc, and both also have pretty good higher-level libraries for games (jMonkey engine, SDL, SFML, Ogre and many more).

You could also consider other languages too. Python has SDL bindings called PyGame. C# has the XNA framework which has several books published for it now to help learning the framework. SFML has bindings for C++, C, D, Ruby and I think Python. All of these are then suitable for creating games in. Just pick a language and off you go.

workmad3
  • 25,101
  • 4
  • 35
  • 56
3

If you ask me, neither Java or C++ are fun languages. Both of them have a number of advantages but if you're doing it for fun and don't have deadlines, I would seek out a language that's more fun. Like Python, or something similar.

Tamas Czinege
  • 118,853
  • 40
  • 150
  • 176
  • i definitely have Python on my list as new language to learn. But its after Java. Presently, i am working with Java. – Ibn Saeed Jun 10 '09 at 09:35
  • 1
    Python is not fun to make games with, however. Even with something like Pygame, it can quickly become complicated. XNA is my favorite mix of high-level programming with fun, easy game development and lots of documentation. – Ricket Jun 10 '09 at 17:11
  • However you did just say that you are presently working with Java, so if you are unwilling to switch to C# despite so many language similarities, then try something high level like JMonkeyEngine or low level like JOGL. – Ricket Jun 10 '09 at 17:12
  • As pleasing a language as Python is, I think it would kill me to try to do a game in it. Unless you want to do just a puzzle game, of course. – Nosredna Jun 10 '09 at 20:41
3

If you want to make games you really need a game platform as well as a language, otherwise you will spend all your time solving basic problems like how to draw a sprite to the screen, rather than concentrating on building a fun game.

Great choices for hobby games development are:

  • Microft's XNA platform with C# language
  • Adobe's Flash with ActionScript language
  • Sun's JavaFX platform with JavaFX script language
  • Unity3D with C# language
  • Ogre with C++ language
Iain
  • 9,432
  • 11
  • 47
  • 64
  • +1 to XNA for game prototyping (and Xbox 360 games!) and C# is similar in many respects to Java. Flash isn't normally for serious games but I'm sure there are a few out there. Ogre can be complicated but is definitely a wonderful professional engine. I just get lost in all its documentation and features and such. Also, don't forget JOGL with Java language. It's basically OpenGL bindings for Java. You get the benefits of the Java language with the hardware acceleration and speed of OpenGL. – Ricket Jun 10 '09 at 17:08
  • Im seeing alot of positive votes for XNA and C#. I think ill give it a look as well – Ibn Saeed Jun 11 '09 at 08:07
2

You can write games using both languages but I think you should really try C++. There are far more high-level libraries and game engines written in C++ than Java so it would be easier to find one that suits your needs. Not to mention that a lot of older games have been open sourced and you can freely download them and study the code. You can guess what language they're using ;)

Also you'll find a lot more tutorials and books that teach game programming using C/C++.

No matter what you choose in the end, have fun writing your games :)

Stefan
  • 1,046
  • 10
  • 9
2

If you go with Java, I recommend Computer Graphics for Java Programmers, by Leen Ammeraal.

If you were developing commercial games you would be using libraries rather than implementing these algorithms yourself, but it's easier once you know the fundamentals, which you can learn from a book like this one.

I once wrote a software renderer for a DOOM clone in Java, and having this book for reference helped a lot.

finnw
  • 47,861
  • 24
  • 143
  • 221
2

C++ is THE defacto language not only for game development but for pretty much everything else, including the browser you are using along with the OS it runs on.

So if you are considering ever getting serious with programming C/C++ should be top at your list.

As for speed C++ IS generally fast than Java. Why generally?Well, the truth is that C++ is faster than Java, is faster than pretty much everything else actually, but sometimes C++ code can be poorly written and Java may prevent beginners to make some mistakes resulting in many of the claims that Java is as fast as C++, there are even claims that Python/Psyco are as fast as C++ and faster than Java.

Keep in mind that no program written for a framework (Java, .NET, VB, etc) will ever run faster than a program that runs on a lower level (direct on the OS or even the hardware) like C/C++, ASM, Pascal and so on.

Take a look at this:

Poorly written C++ half the speed of Java, properly written is much faster

At the end of the day you should go with the language that you feel more comfortable with, remember that python is enterprise ready, commercial, stable, great for beginners, awesome to use on "Web 2.0" projects not to mention that is a lot of fun too.

OldJim
  • 331
  • 1
  • 2
  • 12
  • "Keep in mind that no program written for a framework (Java, .NET, VB, etc) will ever run faster than a program that runs on a lower level (direct on the OS or even the hardware) like C/C++" simply isn't true. – Pool Feb 11 '10 at 21:33
2

Java - I'd recommend sticking to one and getting good at it. The ideas remain the same, and as you learn more about a single language, you'll begin to learn about the drawbacks and advantages that are prevalent in many of the programming methodologies and languages today.

mduvall
  • 1,018
  • 1
  • 8
  • 15
1

Only a hobby? If you're using Java then Java. But first, what are you programming, 2-D or 3-D games? Java does both, and it's my game programing language, but I'm doing only 2-D programs. C++ is the defacto standard for serious game programming, especially commercial games.

Java has a great IDE called Eclipse, which, to me, is worth doing Java all by itself...Eclipse rocks! And it's free.

C# - no. Way too Microsoft dependent.

Btw, Java will work as an applet and as an application if you plan it well, the application runnable on all three platforms...

So, think about it. Low investment, high quality tools, cross-platform. If you decide to get into C++, then that's okay too. At least you will have wet your toes for free... ;-)

S.E. Foulk
  • 111
  • 1
  • 9
1

Language defines target platform and public. Both Java and C++ have advantages and disadvantages. You will use same architectures and algorithms on any platform. If you know how to write a game in C++ it takes a little to write game in java (2 weeks for me http://madeinsoviets.net/). Start learning game programming with C++ and some easy game engine (Ogre3D, irrlight) - much more information and tutorials.

1

Old topic but since people still read this i want to add my 2c since its unique to this post.

Stick with java, its a great way to make games over c++ if your going to do it as a hobby and by yourself for these 2 reasons.

  1. 10x less coding for the same results (albeit it runs about 5x slower)
  2. Android games, even mediocre ones will sell (a buck each) on the marketplace. if you sell even one your going to feel huge pride! (also java doesnt slow down over C++ on android because its JVM is unique and runs against the API directly accessing hardware, which is fantastic!)
Mark Hall
  • 53,938
  • 9
  • 94
  • 111
Thess
  • 21
  • 1
1

Even if you never intend to get into professional game development there is one big advantage to C++, which is that you have a lot more resources available. There are more books, more tutorials online, more open source examples to look at and more people who will be able to answer your questions on sites like gamedev.net.

drby
  • 2,619
  • 25
  • 26
  • 1
    Yep. Not as much stuff out there on Java game development, unfortunately. However using JOGL you can use any OpenGL book and apply it to JOGL, since it is essentially a direct port/bindings of OpenGL. Also the basic game development knowledge that you find in any book can apply to any language, and any special algorithms (such as A*) can be easily ported to Java once you understand the essentials. – Ricket Jun 10 '09 at 17:10
1

I have developed a couple of small games in both C++ and Java and I would select C++ everytime. It gives you the low level control which you just dont get with java. But games development is a whole different beast. So if you are looking to learn games developement start in something you are comofrtable with

gonzohunter
  • 832
  • 1
  • 8
  • 18
1

If you think you may one day want to work in the industry, you should learn C++. C++ is used to make pretty much all commercial games that run on PC/xbox/ps3. I assume wii is the same but don't know 100%, I never worked on wii.

The games studio I used to work at (before it got shut down) used C++ for the game (small parts used C and assembler) and was starting to use C# for tools.

If it will only ever be a hobby, then it doesn't really matter what language you use.

markh44
  • 5,804
  • 5
  • 28
  • 33
1

I would suggest to try Haaf's Game Engine for C. It is very very simple 2D engine with good documentation, tutorials and examples, runs on Windows 98 and above and it is ABSOLUTELY free even for commercial usage!

If you're completely new to game development, it's right for you IMHO.

Michael
  • 903
  • 1
  • 8
  • 16
0

If you are just doing it as a hobby, it probably doesn't matter. Just use whatever you are most comfortable so you can get into the swing of game programming. Once you get better, you might like to figure out what is the "best" language.

1800 INFORMATION
  • 131,367
  • 29
  • 160
  • 239
0

I would definitely suggest C++ if your intention is general game programming. Of course, if you want to develop for a mobile platform such as Nokia and Ericsson then Java might be a good idea.

But if it is for general desktop gaming then definitely C++. If you want to deploy games over the net then flash might also be a good idea.

bobbyalex
  • 2,681
  • 3
  • 30
  • 51
0

If you're planning to enter the industry (or maybe a day start to sell your game yourself), then you have to learn C++.

Java or C# are good choice to get to the point of creating game without worrying much about the machine (memory and speed). That's recommended for beginner, but I would personally start directly with C++.

Klaim
  • 67,274
  • 36
  • 133
  • 188
  • I would only be working on Windows machine. I dont own consoles or ever plan to code for it. So my target is just plain games for windows, either using Java or C++. – Ibn Saeed Jun 10 '09 at 09:28
  • Then one or the other is not important. Use the one your started with and stick to it until the end of your project. – Klaim Jun 10 '09 at 11:55
0

If you're looking into game programming then C++ is the way to go. Sure Java will be good for certain games, but C++ is so much faster.

I've coded in Java before, and then started coding in C++. The time I've spent coding in C++ made me understand certain things that were heavily simplified in Java.

Depending on how much experience you have programming, I'd suggest to learn the basics of Java and then move on to C++.

Charles
  • 2,615
  • 3
  • 29
  • 35
  • I also have decided to go the same path, learn Java first and become proficient in it, then move on to C++ – Ibn Saeed Jun 13 '09 at 21:31
  • "C++ is so much faster" - actually it's comparable http://www.idiom.com/~zilla/Computer/javaCbenchmark.html There's lots of reasons to choose or avoid Java but speed hasn't been that since the 90's. – Pool Feb 11 '10 at 21:36
0

If you start with Java, I recommend this book Physics for Game Programmers

MicTech
  • 42,457
  • 14
  • 62
  • 79
-1

In general, C++ is for real games.

Java has always been slow for me, whatever platform or program I use.

C# is better than Java, but not as good as C++.

Yes, there are exceptions, but the fact that they are so notable rather proves that C++ is just the way to go unless you really know what you're doing.

Paul Nathan
  • 39,638
  • 28
  • 112
  • 212
  • I'd change that last sentence to "C++ is the way to go only if you really know what you are doing". C++ is great, but Java and C# are far easier to learn. – aaaa bbbb Aug 02 '10 at 23:54
  • @aaaa: I have never found C++ as grievous as people say it to be. I do not consider it particularly hard. – Paul Nathan Aug 03 '10 at 14:51
  • I programmed in C for 14 years, then C++ for 5 years. I loved it. Since then I programmed in Java for 2 years, now C# for 2 years. I'd never go back to C++ unless I had to. – aaaa bbbb Aug 04 '10 at 15:45