views:

1984

answers:

20

Hello

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.

+17  A: 

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
That sounds practical. I have searched a bit and found "Killer Game Programming in Java" book to receive quite good reviews. But the book's publishing date is 2005.Should I start off with the same book or any other for using Java.
Ibn Saeed
Also, C# is a pretty easy sidestep after learning Java, and the XNA framework is highly recomended for hobby game developing
xan
I have seen alot of praise for XNA for beginning game development. It is possible to code on Windows, i dont have a Console such as Xbox. Does XNA allow to create windows applications etc.
Ibn Saeed
Xna allows you to create games for Windows, XBox and Zune.
DMMcKinnon
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
Thanks for your review and your experience with the book. So JOGL is Java bindings for OpenGL. So what do you recommend me learning from Killer Game book before going to JOGL. Are there any books on JOGL ?
Ibn Saeed
Ricket, have you done any work with JOGL which you can show. I would like to see what you can done with JOGL
Ibn Saeed
A: 

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
+6  A: 

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.

Kezzer
is Java really slower than C++ or is the difference small ?
Ibn Saeed
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.
Kezzer
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
Thanks to both of you for your responses. Java has always been plagued as being very slow compared to C++
Ibn Saeed
Not if you read _real_ reports on speed comparisons. Java is a great language.
Kezzer
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.htmlIt is also worth noting that Java is used at enterprise levels (thus J2EE). If many big corporations trust it, I do.
Ricket
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
Yes, the Java Speed issues are spread far and wide. I think Java has come a long way from its intial release, which was truly slow.
Ibn Saeed
A: 

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.

Bobby Alexander
A: 

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
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
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
+1  A: 

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
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
+1  A: 

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
+3  A: 

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
+1  A: 

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
Presently, I am only learning it as a hobby, not for commercial purposes.
Ibn Saeed
GameCube was C++. I assume Wii is as well.
Nosredna
+3  A: 

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.

DrJokepu
i definitely have Python on my list as new language to learn. But its after Java. Presently, i am working with Java.
Ibn Saeed
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
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
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
+1 PyGame is very good!
TokenMacGuy
+2  A: 

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 Cosma
C++ is on my list as well. But after I have completed the Java course i am following. I have a game in view, which is open source, its Star Trek Supremacy. Its written in C++.Are there any Java games which are open source.
Ibn Saeed
+3  A: 

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
+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
Im seeing alot of positive votes for XNA and C#. I think ill give it a look as well
Ibn Saeed
+1  A: 

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
Thanks Michael, I will look into it. I forgot to mention, that my beginning programming courses in University were pascal followed by C. Though i dont remember much from those days.
Ibn Saeed
Are there any open source game engines for Java ?
Ibn Saeed
I'm not sure about Java engines. Sorry. Try to ask Google.
Michael
Some open source Java game engines/libraries: JGame, jMonkeyEngine, jogre.
Brandon E Taylor
Thanks betaylor
Ibn Saeed
A: 

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
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
@aaaa: I have never found C++ as grievous as people say it to be. I do not consider it particularly hard.
Paul Nathan
@Paul, 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
@aaaa: k.......
Paul Nathan
+1  A: 

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
Thanks lot finnw, I will look into the book. It might help me along the way.
Ibn Saeed
+1  A: 

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
Thanks for your response Oldjim. I am convinced that I should start with Java, then move onto C++.And thats what Im going to do.
Ibn Saeed
"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
A: 

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++.

Chaoz
I also have decided to go the same path, learn Java first and become proficient in it, then move on to C++
Ibn Saeed
"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
+1  A: 

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
A: 

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

MicTech
Thanks for the reference, ill look into that book as well.
Ibn Saeed
A: 

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... ;-)

Scott Foulk