Help understanding the significance of using Java

Not too sure about that. Depends - syrinth are you looking for a job as a game designer or a programmer? If programmer then it depends on what area you’re thinking (C++ - consoles, Java - android, ObjectiveC - iPhone). If designer then you might be better learning something like Lua which is more widely used for level scripting by designers (maybe try love2d?)

Or just make stuff in whatever language you want. It’s all programming at the end of the day. I was hired to write C++ code when I only had a Java portfolio so it’s not as critical as you’d think.

There’s an interesting blog about high performance Java here: http://mechanical-sympathy.blogspot.com/

Actually, Java can even be faster than C and C++, it’s not new, it was already the case in 2004. Forgetting your prejudices would be better.

Java certainly can be faster than C/C++, it’s just not that often the case. Typical performance is 80% of ‘native’ code, which is mainly caused by the lack of structs, as Cas said.

It would be fun to organize something like ludum dare but for bench marking. For given short time period and semi complex numerical or algorithmical problem. Programming language choise would be free. Fastest code would win but it should also produce correct results. That would measure performance * productivity.

If you want java to win then don’t choose a numeric problem and make sure that it’s pointer intensive and that nobody working on the C++ side has the slightest clue about cache oblivious data structures, temporal hints…actually it would be best if they were clueless about how hardware works. But seriously kids, which is faster is a pretty pointless argument most of the time for our purposes here.

(EDIT: as a reminder…I hate C++)

I’m reading through an interesting book: “Write Great Code: Volume 2: thinking Low-Level, writing High-Level” by Randall Hyde. It’s more for compiler-based languages like C & Pascal, but there are occasional references to Java.

One interesting point they make over and over is that using a compiler doesn’t guarantee the highest level of performance (even though compilers and presumably the JVM as well are continuing to improve). So if there is a stat that Java produces code that is 80% of native, what % does the compiler produce, compared to writing in assembly directly rather than using a compiler-based higher level language?

It seems at the end of the day, there is a big variance in coding depending upon knowledge of underlying machine, and whether one comes up with algorithms that take advantage. My knowledge there is kind of weak. It’s been a long time since I wrangled with 8080, Z-80, PDP-11, that kind of stuff, so this is a refresher, to say the least.

@sproingie - I appreciate the blog reference to “Mechanical Sympathy: Hardware and Software working together”. This looks like a bunch of great info right on this topic.

I would second this.

I’ve seen examples of Java code, where it tries to be as OO as possible. I’ve seen multiple examples were a developer will iterate over the pixels in an image, and turned each pixel into a brand new Color object. Removing that single piece of object creation, and instead working on the pixel as an integer, usually gives the biggest speed up.

But I have rarely encountered big speed issues with Java. When I have, it’s normally that I’m doing a lot of work, rather then Java being slow. Most of the issues I have encountered are around garbage collection; again the idea that it’s ok to constantly create and then let go of millions of objects (such as lots of bullets or heavily adding/removing items from a HashMap or LinkedList). However once you know about this, it is pretty easy to fix (an hour or two work at most). You can use one of the many open source (and well written) collections available online to lower the GC on collections; and by making the other objects (such as bullets) re-usable.

Overall, getting good performance out of Java is pretty easy. I work a lot in JavaScript, and I spend far more time finding ways to speed that up then I ever did with Java.

The less “take you by the hand” you want, the lower you go in languages.
Java is in the end a Virtual Machine, giving you a framework and also limits wich dont exist when writing low-level C code.

Its also a matter of taste and productivity if you like a ready-to-go gameengine like unity, or (total opposite) love hacking in assembler.
Java lets you do a lot, but still remains some boundaries, wich some devs dont want.

Regarding Speed: CPU related performance problems are rather a conceptual error, than related to the used language.
The developer want to do something not very applicable for a (realtime) game, and should rather rethink his approch to the procedure, than why the languagemight slow something down.