If you ever wanted a reason to use a modern langauge...

Object creation in Java is generally no more expensive than C++ - fact. Collection can be a little more expensive (not for much longer on Sun’s VM though). You’re talking about a pathological case here where you have described how to do everything wrong and then want me to design fixes for it. The first problem is: what’s your array of vectors for? No-one knows, so designing an optimised solution for it isn’t possible. The second problem is, you don’t know the actual performance of using the array of vectors in the actual place where it’s being used, as both are hypothetical. So you’re already worried about optimising something that doesn’t have a performance problem that doesn’t exist for a problem that no-one yet knows. This is the kind of thing that C++ programmers do! Write the code for elegance first in Java to fit the design, profile it, and if it’s slow, optimise it. Which might bring us to another issue: just try profiling in Java versus C++. Knockout! C++ IDE crawls away bleeding to concentrate on device drivers and kernels.

Cas :slight_smile:

[quote=“uj11,post:94,topic:26008”]
cough bullshit cough

Object creation time depends on what you stick in your constructor - no different than C/C++.
Object ALLOCATION time is fast, likely faster than C in many cases because you get some advantages with the VM managing the heap.

edit: Cas beat me to it… but he didn’t mention…

One aspect that I haven’t seen discussed much though is that in Java newly allocated objects must be zeroed (or at least act like they are), C++ doesn’t have that requirement, so that might affect speed in some cases. (You just get some bugs along with it :))

Who said it was? I didn’t. On the contrary. Heap object creation is generally much slower in C++. The difference is that C++ has value sematics for objects. You don’t have to create objects on the heap.

You’re jumping to conclussions about what C++ programmers do or don’t. And there’s nothing inherent about Java that guarantees a better design than C++.

Instead of talking in general terms about the elegant designs possible in Java, explain the design you proposed above. It will be interesting to know how it solves the problem I pointed out.

Er, you did:

Cas :slight_smile:

Uggh… these threads are such a waste of time.

@.uj -

1 - Can C++ be faster then Java - YES.
2 - Does this mean that Java isn’t good for game development - NO.
3 - Can Java be used to build ANY game that can be built in C++? - UNKNOWN - Logic would suggest that a game pushing the absolute limits of the CPU may not be possible in Java without bridging to native assembly calls, though a C++ version would probably require that as well. 1-5% of games developed per year may fall into that category.
4 - Is Java faster for development then C++ - YES.
5 - Is there any point about arguing performance issues of C++ vs Java - NO - Unless your game falls into category 3, such arguments are a waste of time and either:
A) show your ignorance of Java
B) show your tendency toward premature optimization
C) show which god you follow in this mostly religious debate
D) show your intent on trolling

Point 2 and point 4 is all this entire thread was supposed to be about. Unless you are developing a category 3 game, then there is no point of this discussion. If you are developing such a game I understand your concerns. If you have particular issues, post them and we can try to help you resolve them. Otherwise, you have fallen into one of items A-D and are wasting everyones time.

Ha ha ha ha

What was the last C++ project you have been in? Besides nothing compares to some well hand-optimazed assembler code by someone who is an expert in this area. Not even a JIT which is way smarter than a C++ compiler optimizer.

Don’t forget to tell this guy that Java can use assembler with JNI just like C++ can use inline assembler. The only possible problem was solved long ago with NIO buffers.

Let’s not get stuck here. I’m arguing a point first posted in #93. Here it is again:

“C++ lets you keep up your data abstractions in lower level code without performance penalties to a much larger extent than Java.”

This is nothing you can design your way out of as you gallantly proposed but then failed to further explain.

The reason for this I think is that object creation (or rather handling if you include the whole object life cycle) is more expensive in Java than it has to be in C++. It’s because C++ has value semantics for objects something Java lacks.

I’m still replying with the OP in mind. The OP expressed astonishment as to why people are sticking to C++ instead of jumping onto something more modern like Java.

I have no particular issues with Java or C++. I know both better than most. I’ve explained my reason for posting in #91:

“I’m playing the devil’s advocate because I like Java. I think now and with version 6 is the time when Java finally is up to it on the desktop. But you have to convince the C++ people so I’ve put myself in their place to collect arguments.”

What I may not be interested in is the kind of stacatto replies you’re offering: yes-no, yes-no, yes-no presented without argumentation in a cocksure besserwissing manner. That’s definately a waste of time especially in a general discussion forum.

What’s so funny? You asked why people use C++ instead of assembly to which I replied:

“It’s because C++ is a porttable high-level multi-paradigm language derived from C with a performance that’s comparable to assembly for a substantial size application.”

It’s roughly the same reason why people are using Java instead if assembly I guess.

A little research from .uj would have hopefully revealed to him what escape analysis is and what it can do for those Java applications that would benefit from it and structs, which is an acknowledgement that certain kinds of operation on IO buffers are hampered by memory bandwidth when used with Java heap objects. However… the case remains to be shown that there is, in fact, any performance problem at all for 95% of games, mainly because few people have actually tried. The closest Java has to a pure Java AAA title is Tribal Trouble, and I don’t see that suffering from performance problems.

So we really ought to drop the whole issue of performance, because it’s really not an issue. As I said, as a development manager now, my primary concerns now are deployment, time-to-market, quality, and skillsets. Seeing as there’s no JVM on XBox or PS, I’m not going to go near Java for a AAA title, end of story, even if all the programmers I can find hate C++.

I know he’s playing devil’s advocate here btw, just like I do from time to time - don’t mistake him for a troll :wink:

Cas :slight_smile:

Not quite - I was surprised given that modern languages have been viable for games development for a few years why there has been almost no detectable move to modern language. Check out the adverts in the back of GameDev magazine - almost nothing to do with anything other than C++. I’m not surprised the dev’s didn’t “jump onto something more modern” the minute it was available but there hasn’t been much movement in the years that the languages have been useful.

So far from my blog and here I have the following observations (Java related since I don’t really ask about much else :)):

  • The console hardware/software isn’t anywhere as far as long as I’d originally thought. I can now understand pefectly why Java isn’t used there yet. Its simply a matter of not enough low level access.

  • Java is still attached to the “slow” stigma (whether shown to be less than accurate by games like Wurm, Tribal Trouble and MegaCorps).

  • There has been a lack of marketing with respect to Java for Games (no belittlement to what ChrisM, Jeff and others are doing at the moment). Game developers that I’ve been contacted by recently just don’t even think of it as an option. (C# is apparantly growing in this area)

  • I used to think the only way to convince game developers that Java was a good idea was to show them complete projects in which Java was used succesfully - however, this doesn’t work. You generally get a “hmm, yeah, but X, Y, Z high tech graphics features arn’t in that game are they?”.

  • Games design/source/development hasn’t reached the level of complexity that other applications have - otherwise the benefits of modern langauges (Java/Ruby/C# whatever) would be blatantly obvious. Game life appears to be getting longer and the detail level higher - in time I suppose things will shake themselfs out.

  • Converstaions/Threads like this don’t help anything due to their zealoty type nature.

Just observations as I’ve received mails, comments on the entry and reading this thread.

.uj have you started developing a game in Java? Will you given the conversation here?

Kev

Oh, yeah, I take it back, not a Troll… I just looked it up:

I guess the early insult knocked you into this category for me at least; “unfortunately, many users react aggressively on a first impression to a perceived troll, which sometimes leads disgruntled newbies or political minorities to be perceived trolls.”

I love the idea of someone who doesn’t jump to Java’s defense as a “political minority”. :slight_smile:

Kev

If your as experienced in C++ and Java as you claim, then you should already have the answers.

Sometimes there really are yes and no answers and everything else is just clouding and misdirection. The questions I posed are simply and accuratley answered with those two and three letter words. I choose to simplify the questions and responses to eliminate the possibility for you or anyone else to misdirect the discussion further. However, here are some statements to backup my “cocksure” answers:

1 - Can C++ be faster then Java - YES. -

C++ can do some forms of data manipulation faster and often has a more direct route (less abstraction) from the hardware, therefore there are areas where C++ can exceed Java’s performance.

2 - Does this mean that Java isn’t good for game development - NO.

Several games have already been developed in Java - covering everything from simple 2D to 3D using the latest video card capabilities - across all game genres. The language is turing complete and sufficiently performant enough for 95% of the games one would want to develop.

3 - Can Java be used to build ANY game that can be built in C++? - UNKNOWN - Logic would suggest that a game pushing the absolute limits of the CPU may not be possible in Java without bridging to native assembly calls, though a C++ version would probably require that as well. 1-5% of games developed per year may fall into that category.

No one has built or attempted to build a truly bleeding edge engine in Java as of this time. So there is no proof either way.

4 - Is Java faster for development then C++ - YES.

There are many examples out there of this, but I’ll give you one of my own.

My company is owned by an umbrella company which is ranked as the 6th largest software developer in Canada. In 2002 I was hired to hire a team and design a rewrite of our core product from the ground up. I choose to use Java and the project was completed on time and under budget 2 years later. Four of our sister companies were challenged at the same time with the same task. None of them succeded and all but one was eventually cancelled (they were using Delphi and are close - 2 years late, but close). Two of the projects were in C++. Our parent company was very upset (millions of dollars wasted) and hired consultants to evaluate the projects. The C++ projects both had more resources and the scope of the products they were developing were substantially smaller. Primary reasons sited for the falures was technical complexity inherint with the technology platforms chosen. As the size and complexity grew, the development slowed and stalled. Our product was the only one that was finished, the only one under budget, required the least resources, was the largest project (functionality wise - 4.5 Million lines of code) and is the only one that runs on multiple platforms. I got promoted to director of R&D for being the architect of the project and our parent company has me consult on all the techology decisions being made across the various companies for anything with a budget exceeding a million dollars.

Ton’s of other stories exist. It’s the nature of language design. Eliminate the pain points to improve the productivness and simplify the solution.

5 - Is there any point about arguing performance issues of C++ vs Java - NO

People see what they want to see. We can go back and forth for a millenia and be no further in this discussion. That’s why it’s a waste of time and there is no point.

Thats exactly the same reason why people are shifting from C++ to Java and for the reasons i explained above if you understand something about compiler optimization and how it is evolving. The funny part is how your answer reminds me of some very old hype about C++ that never become a reality and only got worse with the passing years. While Java hype is already a reality. C++ is dieing and being replace by a combination of either Assembler + C for low level and critical code and C# or Java for what was before the C++ domain. Java competition is not C++ but C# and other modern languages.

I know about escape analysis and it fits very well into my general argument regarding why people stick with C++ instead of jumping onto the Java bandwaggon. Already from the start Java has claimed to have the potential of being faster than C++ very soon now. Well let’s hope it finally happens with version 6 after 10 years of wait. But I seriously doubt it. Java seems destined to always be the future kid.

1a - Can Java be faster then C++? YES
Witness any FFT shoot off thats ever been done. I don’t knwo why exactly but it seems thats a particularly good problem for Java.

What logic? Java is compiled just like C. Java has more information available about the target system when it compiles then C does, being a run-time compiler.

If anything, logic says that Java should be able to actually beat C code in terms of raw assembly generation.

Here I agree. a thorough waste of time EXCPET that such misinformed nonsense can lead people who really DO want answers to the wrong conclusions. This is the reason i take a certain amount of time to answer them. But its worth only so much effort…

Well it’s really very good of you to beam down from the mothership once in a while to reveal the secrets of Java to us mere eartlings.

So you propose that the the assembly to high-level language shift can be compared with a C++ to an even-higher-language shift.

That just shows your lack of perspective. The former was a huge evolutionary leap. The latter is just a small step in evolution. You may have noticed that C++ is also a .NET language. Microsoft is treating C# and C++ on an equal footing with C++ as “Horsepower with a finer degree of control than other Express Editions”.

Thank you for replying. I know both C++ and Java very well and that’s exactly why I find it so difficult to decide which one is better in a given situation. I also think I know why C++ still is preferred in gaming but I don’t necessarily consider that “fair”.

When you talk about C++ for the .net platform you are talking about memory-managed C++. At that point there isn’t really any difference between it and C# - they are both compiled to MSIL and run on the .net VM and I woudl be very surprised if there was any performance advantage to C++ over C#. If you’re using unmanaged C++ then you’re presumably still stuck with the arcana of memory management and the productivity/performance payoffs that entails.

All of which reminds me that this is an argument that I absolutely do not care about in the slightest -the only games I can think of that were improved by the language they were written in are the old SCUMM ones because SCUMM let them concentrate on making good games and possibly an arcadey beat-em-up of a few years ago that used python for in-game scripting and was supremely moddable for it - and I’m not even sure what anyone is talking about by this stage, except that I agree with Kev that regardless of language a lot of game development houses seem to be stuck 10-15 years in the past as far as development practice is concerrned. How that became such a hectic discussion of C++ I really don’t know.