I've just been trying to learn to do C++ Win32 programming using Visual C++, and I've given up on it because it was co complicated. I read somewhere that learning java beforehand makes learning C++ easier. I've looked at the java language and its way easier than Win32 C++ (in my opinion). So I was hoping for my Java skills to be a full path not just a step towards Win32 C++. But there's a problem. I've read in an article that Java is about 20 to 50 times slower than C++. But it also said it keeps getting upgraded to make it faster. Another thing that is bothering me in java is the buttons but im quite sure that you can change them. Another thing is that I've never heard of a commercial game that is made from java. So can someone tell me more good points about java and the commercial games that were made by it?

I don't advice anybody to learn C++ the days. C++ is kind of the COBOL of this millenium. It's ugly and difficult.

But C++ IS the de facto gaming standard language today for mainstream games. No way around that. So if you want to write a AAA, mainstream title NOW, use C++. But can you really do that? It's LONG way from learning a language to writing a AAA game. 5 years?

Much closer would be to write simple (or not so simple) applet games? Learn the principles of OO? Java is good for that.

As I mentioned, learning Java takes you far away from knowing C++. But maybe, in 5 years, C++ is no longer a must. I don't know wether Java will be the no.1 language that (to be honest, I doubt that), but I'm quite sure the one of the newer languages around (like Java, C#) will be the language of choice.

And - you can use you Java knowledge very good if you don't do games.....

> so what do you think i should do then? Forget about java and learn C++?

I suggest to use Java. In contrast to C++ it's is a real high level language and not an macro assembler hacked for OO. It allows you to do your tasks faster and more robustly. Also its giant library lets you concentrate on your task, so no need to re-invent the wheel all day.Compared to my C++ experience, Java is a real pleasure. I still don't understand many things, but the learning curve is much smaller and more fun, also because of the execellent documentation (javadoc rules!).

This all applies to "typical" applications.So now it depends on what game you want to do. If you take a look at Alien-Flux ( http://www.puppygames.net/ ) you'll see it's well possible to do fast action games with cool graphic and sound effects in Java (with OpenGL).

For a "typical" game (not Doom3), like 3d/isometric real-time strategy games, there are two critical topics to consider.

1) The graphics output. Luckily today you can deligate most of the "pixel transfer" to OpenGL, so that you "just" need to know how to use the OpenGL API in the right way. To master this isn't easy at all, but it doesn't matter if you call the API from within Java or C++. Much more important is to reduce the amount of data which is sent to OpenGL. This mainly depends on clever choice of algorithms and data structures. I bet somebody who knows how to program Java in the right way can do this task nearly as efficient (90-95%?) in Java compared to C++.

2) Simulation/AI. Again the clever choice of algorithms and data structures is the absolute main point. Practically nobody programs a full price game's AI in a low level language like Assembler anymore (*), although from a "CPU cycle per second" view this would be faster. The right algorithms are the joker, while the choice of programmings language is minor (so use the one which helps you most: Java). Many of today's full price games use interpreter languages _inside_ their C++ to do the AI tasks, because so the developers reach their goals more efficiently (on the same time they laugh at Java because it's a interpreter language?). A few commercial games (like Sturmovic) used Java for their KI and other parts (the graphics engine has been in C++ - but this has been before Jogl's been there).For many real-time strategy games the simulation/AI does take more CPU time than the graphics system. A ratio "AI to gfx" of 2:1 isn't unusual.

Well, I'd say games which rely on CPU brute force (Doom3 because the CPU has to help the graphics card a very lot, etc) will be faster in C++ compared to Java.However many other games could well be done in Java, if your target PC isn't an old 300 MHz without a 3d card. :-) The Sims, Zoo Tycoon, Monkey Island 3, Runaway: A Road Adventure, and probably most of the other adventures, role playing games, and many real-time strategy games.

(*) The exception being the fantastic Roller Coaster Tycoon game from scottish braveheart Chris Sawyer. This game has been programmed entirely in Assembler, and it's for sure the fastest isometric strategy game I've ever seen. And it flies on a 200 Mhz PC with no 3d card. Ha! :-)

OO is short for "Object Orientated" programming. For example the difference between C and C++ is the OO part of C++.

Javadoc is a tool of the Java SDK and is used to generate nice HTML output of your codes's documentation which should use the Javadoc commands in its class and method comments.http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.htmlIf you watch the Java API documentation, for example here: file://localhost/i:/Sprachen/Java/Jdk1.4.2/api/overview-summary.html all this is being produced with Javadoc from the original Java API sourcecode.So: no seperate source code and documentation anymore, but both in one, so it's always up to date etc.

The last years we've used Doxygen for our C++ applications, which is a kind of "Javadoc for C++".

You obviously wont find too much C++ love around here. It is a big bulky language, no doubt, but it's not exactly horrendous and definitely still has its place. (But don't be surprised to see languages like python, C# and of course Java continue to eat C++'s marketshare).

<misread original post>What are you using to learn C++, I mean book/class/website wise? That can make all the difference. C++ definitely gets very complex as you go, but shouldn't be too bad to begin with. Maybe your approach needs reconsidering.

As for the 20-50 times slower, maybe in 1996 it was (if it was ever that slow). Java has come a loooong ways in speed, it's far closer to C++ nowadays.

Most of the larger scale java programs seem alittle slower than C++. Like NetBeans and Alien Flux (But that game rocks!). And as for the clever Algorithms wouldnt it be the same speed increase if used for c++? So is making an interpreter in Java that makes games suitable? Or is using c++ better?

I will say that Java is much easier to learn algorithms/data structures with. The Java2D also helps start you out with graphics. The nicest thing is you don't have to worry about the Win32 API.

C++ is a very powerful language, but as my Professor says, "C++ is a huge language. Most of the 'C++ Gurus' only touch a small part of it and are afraid to explore any farther." And yes, I did learn C++ before I learned Java. The transition was easy. Going back to C++ when school started, on the other hand, wasn't quite as easy. Damn pointers...

The speeds of C++ and Java are very comparable. And Cas can correct me if I'm wrong, but AlienFlux was compiled to native code using JET, right? So then the fact that it's written in Java should not make any noticable difference.

An interpreter for games in java is possible, particularly because Java has a built in regular expressions class. However, what I would advise is to learn the theories and use Java as a tool to use what you have learned. When you're ready for a game interpreter, then pick a language that is good for parsing.

And as for the clever Algorithms wouldnt it be the same speed increase if used for c++?

Sure; however what I tried to say was that to select the correct algorithms and data structures is by far more important than the programming language you use to implement it.With C you can be faster than with C++ because you've got more direct control of what the compiler produces. Same applies to assembler.Still, hardly anybody uses plain C or assembler for a game's simulation/KI part anymore (has been different 10 years ago), because 1.) if you got the algorithms right, the very minimal spead increase you could gain with a more "low level language" isn't worth the hassle (and compared to Java C++ is more low level). And 2.) you'll reach your goals faster and more efficient with a high level language. Time/effort is a very big factor in (games) industry.

Quote

So is making an interpreter in Java that makes games suitable? Or is using c++ better?

Using an interpreter in an interpreter language is more straightforward. :-)There are several easy to use script approaches for games with nice interpreter languages. A previous poster mentioned regular expessions (in Java since ... Java 1.3 or 1.4 ?) which indeed is a big pro for parsing scripts and implementing an own simple script engine.The point is: since many C++ games run their AI in an interpreted way anyway, interpreter languages are used actually in many games.

Yes, AF is available as a Jet-compiled EXE... I'd be interested to know which bit of AF is "slower than C++" though seeing as there's nothing to compare it to... that and the fact the bottleneck is in the graphics card fill rate and bus bandwidth... (run task manager and note the CPU usage)

I personally never got good results with JET, but esp. AF runs absolutely smooth even from a WebStart launch and I guess the CPU is nearly idle. So I don't think there would be any benefit for C++ here.

<OT rant>Uhm, being both a user of Netbeans & Eclipse I can certainly say that Eclipse isn't always as fast as most belive (sure the common case of 10 files makes it seem fast).

Generally Netbeans is *slower* than Eclipse, because it is SO much more feature packed! And is a lot more extensible than Eclipse!

Try working everyday with both programs. You will quickly realize that Eclipse is faster to open files and whatnot. But in terms of actually producing stuff, Netbeans is far better.

The perception of performance is very subjective!I have a relatively fast computer - so both run fast. Thus I only care about what makes it easier for me to develop in.

Generally for simpler projects, Eclipse is better - but for J2EE and other complex stuff - NB is quite a bit better.

My main gripe with Eclipse:Even a simple thing as cvs over ssh using plink (source forge projects, typically) doesn't work using Eclipse! You need to use they're "special" cvs thingy, rendering commandline unusable. Supposedly working on this though...

Ohh and not forgetting:SWT is *much* faster than GTK2, Motif or Photon. This also has to be evaluated when selecting an IDE.</OT rant>

Netbeans lack refactoring tools. That's the main reason I use Eclipse. (And I HATe the Netbeans UI structure - it's near impossible to configure the dang thing.)

In general (staying on topic) the tools for Java are better than for C++ I find.. sure Visual Studio .NET is nice.. but ti lack refactoring tools as well. The reflection information in Java class files makes some advanced tool development much easier in Java. Like auto code completion of methods for which you don't have the source code etc..

For Java, there is NetBeans, Eclipse, JBuilder, IntelliJ, JCreator, CodeGuide, Together ............................. and you can all use them on the same project!! Choose your personal IDE of the day!

Moving BACK to the original topic of this post, I would like to ask you folks WHY this issue of Java versus C++ keeps coming up (aside from the obvious answer of new people who just become aware that this is a seven year old debate)? From a market perspective, is this REALLY such a big deal?

I'm very aware the number of commercially available Java-based games can probably be counted without taking off my shoes. Nevertheless, does Java still have the stigma amongst developers (not the users, they haven't a clue - no disrespect meant) that it's not usable for games?

Not until, I suspect, we get a few much wanteded features in the language and JVM, these being: static import (so code looks natural and uncluttered to migrating C/C++ programmers); generic types, for the same reasons; and structs, to enable efficient buffer manipulation. All three of these things are effectively "missing" from Java currently, and to any sensible C++ programmer, you'd simply be taking a big step backwards to do without them.

NetBeans is slow, but NetBeans uses Swing extensively. That's more a Swing problem than a Java problem.

I think the very nice text editor Jedit (www.jedit.org) is pretty fast, too. And it uses Swing. :-)Usually when I showed it to new colleagues who didn't like Java they didn't even notice it's been Java. :-) (on a 700 MHz PC.)

Gaming industry has a successful history with C++! There are the people, the tools, the know-how. C++ is proven to work and there are lots of best-practise examples. Why change? Not just bc. a poor developer says he likes one language more than another.

'Its possible to do that in Java, too' is no sufficient reason to change. There has to be a clear and BIG benefit!

'Its easier to code' helps the coder a bit, but not the customer. And the business looks at the customer!!

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org