Java : Considered harmful.
Let the flames begin. They always end up happening in other threads anyways, so perhaps the debate can be centralized here.
There are lots of Java vs. C or C++ benchmarks out on the web, for all kinds of problem domains, with all kinds of benchmarking methodologies. Getting people to agree on a benchmarking methodology is hard by itself. I like the Computer Language Benchmarks Game because it allows you to change the benchmark weights to whatever you like. Using the default weights, I'm seeing Java as 50% slower than C++.
When is 50% important? When every last drop of performance counts. That's not true of a lot of games out there, especially the casual games that are so popular around here. It's not even true of games that make modest use of a 3d engine, that aren't particularly demanding. But if you're trying to squeeze every last drop out of the CPU, to get every last geometry or physics calculation up on the screen, then 50% matters. I get tired of hearing that 50% doesn't matter, because sometimes it does. There's a reason that nobody's writing 3d device drivers in Java, for instance.
Another tiring argument is that it's all going to depend on the 3d HW's fill rate or vertex processing anyways, so who cares what language is feeding the 3d HW? Well, when you're doing performance oriented stuff, you have a lot to feed. Yes there's such a thing as being CPU-bound and yes going 50% slower can contribute to it. It's tiring to hear that this sort of thing never happens, because it does. No it doesn't happen for every problem out there. If you can avoid it and it isn't your problem, great. But it's some people's problem, and acting like it's never anyone's problem is just dumb.
Java : Considered harmful.
I like Lua.
And if performance truly mattered then Flash would be dead.
The reason I use C++ is it's integration with numerous (great) libraries out there.
What is the purpose of this post? Public awareness? I think the defenses of Java that you mentioned are valid in many (possibly most) circumstances, but everybody needs to do a little research and make their own decision about what's appropriate for a given project. Personally, not once have I selected a language or library based on raw performance as the primary concern.
Bvan, have you ever made a positive post on this board? Seriously, I know whinging on boards is therapeutic, but can you spread it around to other boards a bit?
"Don't lose your loose change."
Jason Maskell, Tamed Tornado Software
This thread arose because Cas and I have this ongoing war where he says Java can do everything just as well as C++. I say no, when maximal performance is a hard requirement, it cannot. There are portions of the 3d industry where maximal performance is indeed a hard requirement, and that's why Java hasn't made headway in those market segments. It's not because the C++ guys are culturally brainwashed, habituated, deluded, stupid, NIH, or whatever else Cas thinks. Yes, some language advocates are like that, but others are going very strictly by what the performance data tells them.
Seriously, Java has it's good and bad points when it comes to performance. The good part is that the performance is based a lot on the VM so with VMs like HotSpot in J2SE6 and on, which do optimize your program in the runtime depending on how it runs (versus the static optimization which C/C++ compilers do based on guesses), they have a greater opportunity to produce faster code. Also with you doing nothing, you get faster execution every time a more improved runtime comes out.
The bad part is that Java is not a good language for classic low-level optimization techniques, like pointer-based optimizations, lookup tables, etc. Also where arrays are used a lot (software rendering or heavy image manipulation, realtime sound synthesis, etc), Java is slower than their C/C++ counterparts, unless they're used hand-in-hand with the VMs array optimizations (which as far as i know exist only in the server VM).
In any case, writing the exactly same thing in both C++ and Java is going to make either Java or C++ the faster language. You cannot write in Java as you would write in C++ and you cannot write in C++ as you would write in Java and expect fast results. Each language has it's own cases.
Note that when i'm talking about Java i mean the Sun's latest version of compiler and runtime. Not others and especially not the crappy Microsoft VM.
The focus is on creating indie games and all that entails. If it takes 3 lines of code in language X to implement the same functionality as 300 lines of code in language Y then I would consider language X to be more optimized.... for the Indie developer. I would aslo hazard a guess that the majority of the members of this board would gladly incurr a 50% performance penalty at execution time if that translates to a 50% performance savings in development time.
Anyway, if an indie developer finds that his game is CPU bound then his first step should be to crack open a book on algorithms; before trying to make the jump to lightspeed in an asteroid belt.
Not a bad idea, but algorithms aren't always the issue.Anyway, if an indie developer finds that his game is CPU bound then his first step should be to crack open a book on algorithms; before trying to make the jump to lightspeed in an asteroid belt.
Do you realize that whipping random qualifications out of your ass to make you sound like an expert is lame? (No, I don't care if you've worked on CMake or written device drivers. That's worthless to people looking for help when deciding on GameMaker vs. Java.)
I got five stars on Heart Shaped Box on expert in Guitar Hero 2, and I say you've got an oddly shaped head. So there.
That's very interesting that the Java port runs faster in some circumstances than the original C code - and this is Quake 2 we're talking about, so one imagines that it was pretty well-optimised C code to begin with (since id software do seem to obsess over performance a lot). Though the framerate numbers are so high regardless that I wonder how statistically significant the variations are. Probably the safest way to put it is that there's no noticeable difference in speed.
I still think Java code is overly verbose though. Maybe I'm just too hard to please.
Do you realize that having no idea what the IGF judging is like before you spout off about its irrelevance is lame?Do you realize that whipping random qualifications out of your ass to make you sound like an expert is lame?
Wrong thread. Deal with this one.(No, I don't care if you've worked on CMake or written device drivers. That's worthless to people looking for help when deciding on GameMaker vs. Java.)
Unfortunately, so far the installations for all these modern Quake II ports are shit. Well, I'm not surprised. This is how I became a CMake guru.
Oh, and for Jake2 I'm getting 85 FPS on a 3.2GHz Pentium 4 with an ATI Radeon X300 on Windows XP. I've got both JRE 1.5 and 1.6 available, I don't know enough about Java to know how it goes about differentiating them. To give the Bytonic guys the benefit of the doubt, I'd say I haven't reproduced their benchmarking methodology yet. I wonder if I'll be able to, since I'm using both a faster computer and a faster 3d card than they used.
Not that there was ever a question or a real invitation to a debate that would be heard with an open mind, but allow me to interrupt the pissing match with a response to the original statement: Who cares? If you do, use C++.
I look at benchmarks, some Java people look at benchmarks. We debate benchmarks. The people who don't have any benchmarks and are only capable of snide remarks are useless. That doesn't mean there's no debate though.that would be heard with an open mind,
Some Java people want to convert newbies to Java rather than C++. I don't have any problem with that if it's based on correct information about the strengths and weaknesses of the languages.but allow me to interrupt the pissing match with a response to the original statement: Who cares? If you do, use C++.
I'd be quite happy to see real evidence that Java does in fact equal the performance of C++ for compute intensive tasks. So far, the benchmarks I've seen that attempt to demonstrate that, smell funny. Goading people is a way to get information out of them. Some people put a lot more effort into making their case when they don't want to be wrong.
It's 3 am and I've had enough of this crap for now. By "crap" I mean, ID's Quake2 3.21 code doesn't build on XP, their demo doesn't install on XP, various people's Quake II ports don't work any better. This is proving to be a difficult benchmark to duplicate and I'm losing motivation. One last stab at Google to see if anyone's already discussed Jake2 performance ad nauseum.
What is the point in this thread? Perhaps I missed it, just seems to be a rant about how poor Java is when compared to C++ in the performance arena? Java tends to be easier to manage and (from my experience) has less pitfalls, that is worth the drop in performance in my book.
Lets face it Object Orientated languages rarely wear the performance crown anyway and I can't see many developers dropping back to Assembly or machine code just for the sake of an extra couple of frames...
man, I am seriously disappointed not to see cas here, FIGHT!!!!!
I do agree with the poster on one side issue though. Not all indie games are completely unconcerned about performance. We are not ALL making bettys beer bar clones here. For some of the code in some of my games, performance is mega mega critical. If you are talking about casual puzzle games, please call them casual puzzle games, do not lump us all in together.
Ok, Q2 demo worked on Vista, surprise surprise. I finally figured out how to turn off vsync. I have a 2GHz Intel Centrino Duo, GeForce 8600M GT with crappy drivers. My JRE is 1.6 OEM Sun Microsystems.
In windowed mode:
640x480: Q2-3.16 gets 225 FPS, Jake2-0.9.5 gets 100 FPS.
1280x960 : Q2-3.16 gets 165 FPS, Jake2-0.9.5 gets 100 FPS.
I can't duplicate the claims of the Bytonic benchmark. The performance difference is in line with other C/C++ vs. Java benchmarks I've seen. I am not inclined to believe their claims without corroboration from other sources.
And with that, I sleep. It is 4:45 am and my work is done for today. Er, yesterday.
Yes there are career points to be made. C++ leads you in certain directions, Java leads you in other directions. For newbies, there's more to a career than shipping their own indie games. They may want to work in the game industry for a time before striking out on their own. They may want to work in related industries such as 3d graphics as consultants. As far as the data I've seen, there are factual reasons why Java hasn't taken over everywhere. Yes there are a lot of things you can get done in either C++ or Java just fine. Yes you can get some productivity advantages with Java, for many types of problems. But not all problems. Performance optimization jocks have good reasons for going the C++/ASM route, it's not just cultural brainwashing or people being stuck in their ways. People like myself have monitored the performance of Java on and off for more than a decade. Our choices are going to be grounded in technical reality until Java's performance does indeed match C++ in all respects.
Right, sleep. 5 am.